Page 1 of 1 1
Topic Options
#51502 - 2000-09-16 03:34 PM need help with FOR
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
This isn't a place for it... but the talent is here...

I need the CMD syntax for the FOR command. Specifically, I need to copy all *.doc files from C: and subdirs to the H: drive...

I believe that it would look something like:
for /r c:\ %1 *.doc do copy %1 h:\doc

Any help would be appreciated.

_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#51503 - 2000-09-16 08:25 PM Re: need help with FOR
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
got it...

This is a batch file to prep a user to be moved onto a new PC (or just to back up their files or whatever)

Assuming m: to be the user home drive...

code:

@echo off
md m:\Word
md m:\Excel
md m:\PowerPoint
md m:\Outlook
md m:\Publisher
md m:\Favorites
md m:\Desktop

for /r c:\ %%a in (*.doc) do xcopy "%%a" m:\Word /y /s /i
for /r c:\ %%a in (*.xls) do xcopy "%%a" m:\Excel /y /s /i
for /r c:\ %%a in (*.ppt) do xcopy "%%a" m:\PowerPoint /y /s /i
for /r c:\ %%a in (*.pst) do xcopy "%%a" m:\Outlook /y /s /i
for /r c:\ %%a in (*.pub) do xcopy "%%a" m:\Publisher /y /s /i
xcopy "%userprofile%\favorites\*.*" m:\Favorites /y /s /i
xcopy "%userprofile%\desktop\*.*" m:\Desktop /y /s /i


there has to be a law against working on a Saturday....

[This message has been edited by Radimus (edited 16 September 2000).]

_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#51504 - 2000-09-18 04:52 PM Re: need help with FOR
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
Open up this file in your NT system: C:\WINNT\system32\ntcmds.hlp

Also both of these sites give some excellant examples of its use.
http://www.jsiinc.com/reghack.htm http://www.Windows2000faq.com/

Note in a Win9x client environment FOR is not very useful.

_________________________
Jack

Top
#51505 - 2000-09-18 05:38 PM Re: need help with FOR
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
I've been refining it a bit, but it is getting better.

code:

@echo off

if exist "c:\program files\ase\data\aspen.mdb" md "h:\aspen" & move "c:\program files\ase\data\aspen.mdb" "h:\aspen"
if exist "c:\cognos\BI96\workspce\*.imt" md "h:\improm35" & move "c:\cognos\BI96\workspce\*.imt" "h:\improm35"
if exist "c:\My Documents" md "h:\My Documents" & move "c:\My Documents\*.*" "h:\My Documents"
if exist "%userprofile%\favorites\*.*" md h:\Favorites & move "%userprofile%\favorites\*.*" h:\Favorites
if exist "%userprofile%\desktop\*.*" md h:\Desktop & move "%userprofile%\desktop\*.*" h:\Desktop
if exist "%userprofile%\Personal\*.*" md h:\Personal & move "%userprofile%\Personal\*.*" h:\Personal
if exist "%userprofile%\Application Data\Microsoft\Templates\Normal.dot" md h:\Normal & move "%userprofile%\Application Data\Microsoft\Templates\Normal.dot" h:\Normal

md h:\Word
md h:\Excel
md h:\PowerPoint
md h:\Outlook
md h:\Publisher
md h:\Access
for /r c:\ %%a in (*.doc) do xcopy "%%a" h:\Word /y /s /i
for /r c:\ %%a in (*.xls) do xcopy "%%a" h:\Excel /y /s /i
for /r c:\ %%a in (*.ppt) do xcopy "%%a" h:\PowerPoint /y /s /i
for /r c:\ %%a in (*.pub) do xcopy "%%a" h:\Publisher /y /s /i
for /r c:\ %%a in (*.mdb) do xcopy "%%a" h:\Access /y /s /i
for /r c:\ %%a in (*.pst *.pab) do xcopy "%%a" h:\Outlook /y /s /i

net use | find /i ":" > H:\%username%-Drivemappings.txt



_________________________
How to ask questions the smart way <-----------> Before you ask

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 302 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.051 seconds in which 0.022 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org