Discussion Locked

Batch file

0 helpful
11 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

How can I create a batch file that will search the local drive for any .XLS .DOC .PDF files in NT,98,95 and copy them to a folder on the network.
Can someone help me out.

11 replies

by rbgnr111

xcopy /s /e *.xls N:\dir
xcopy /s /e *.doc N:\dir
xcopy /s /e *.pdf N:\dir

substitute the drive mapping and the dir for N:\dir

by loudeb

That does not work I ran it and it just flashs really quick and it doesn't do anything.

by ben112

This worked for me at the command prompt, substitute N:\ for a mapped drive on your network.

by ben112

The problem is that it copies directories and it would be nice if you could just strip the files out and place them all in one directory.

by dnme

to find your files with the given extensions at the command prompt or in a batch file type the following;

dir /s c:\*.doc *.xls *.pdf

the s switch looks through sub directories.
as for the backing up... i'll get back to you later.
(using Windows NT)

by dnme

rem you can use this command if you wish but it is not necessary if you use the 'i' switch

md d:\mark\test

rem line 4 copies any doc files and moves them to the specified directory, in this case d:\mark\test

xcopy c:\*.doc /s /i d:\mark\test >> C:\WINNT\Profiles\internet2\Desktop\xcopylst.txt

rem line 6 copies any pdf files and moves them to the specified directory, in this case d:\mark\test

xcopy c:\*.pdf /s /i d:\mark\test >> C:\WINNT\Profiles\internet2\Desktop\xcopylst.txt

rem line 8 copies any doc files and moves them to the specified directory, in this case d:\mark\test

xcopy c:\*.xls /s /i d:\mark\test >> C:\WINNT\Profiles\internet2\Desktop\xcopylst.txt

rem In each case the output is placed into the file xcopylst.txt, I use this as a log file myself but
rem again it is not necessary.
rem Switches - s = include subdirectories, i = assume (and create) directory
rem The l switch can be used to get a list of all the given file types without copying them (kinda test)
rem Once completed you can carry out your backup as per normal and include the new directory.
rem Finally, to copy over a network check out the following switch;
rem /z "Copies over a network in restartable mode."
rem This should work on win95/98 but has not been tested on them.
rem Hope this saves you loads of time and hassle - enjoy.
rem Mark

I sometimes wonder if you have given up on an answer to this one!!

This discussion is closed to new replies.