View Full Version : Batch file HELP!

11-03-2002, 05:23 AM
Hi, I know this maybe seems a it basic but I am just starting to experiment with batch files.

Problem - 100+ users on NT4 standalones in remote locations, all moving to network NT4 boxes, all using MS Office 97.

On standalones all data is kept in folder called DATA in root of C:

Create batch file that moves all data into correct folders ready for network machines e.g *.doc must be in word folder etc.

I have created a file that will nearly do it, but only if all files are in the folder DATA and not in any subdirectories which most are as the users have created their own subfolders.

How do I make the Copy *.doc command also go into all subdirectories.

I hope someone can help.

As an extra how do I add a Yes / No option for the User to answer for e.g "Have you already backed up your Data, press Y to continue"

I know this isnt proper programmng but i thought this was the closest area.

@echo off
md personal
cd personal
md Word
md Excel
md powerpoint
md Access
md General
cd Data
copy *.doc c:\personal\word /v
copy *.xls c:\personal\excel /v
copy *.mdb c:\personal\access /v
copy *.ppt c:\personal\powerpoint /v

Many Thanks for any help


11-03-2002, 06:53 AM

By all means if theres an easier way then just say

Many Thanks for your time.

david eaton
11-03-2002, 07:56 AM

Whoops, where's my old DOS handbook!

If instead of using the COPY command, you use XCOPY with the /s switch, it will search subdirectories (sorry- folders!) for the files.
What I don't know is if XCOPY is available in NT!

hope that helps


11-03-2002, 08:43 AM
For NT Xcopy syntax look at: http://www.robvanderwoude.com/ntxcopy.html

Try using /L while experimenting.

To add the choice you need to use CHOICE.COM which is part of DOS. You will probably need to get it from an older Win95 or Win98 machine with all of DOS installed (or a Win9x CD, in the OLDDOS directory I think). You will also need to distribute it with your batch file. Easiest thing is to put it in the same directory as the batch file, so the batch file finds it.

Then you structure your batch file something like this:

echo Choose an Option
echo ----------------

echo 1. Start
echo 2. Exit

choice /C:12 Your choice:
if errorlevel 2 goto END
if errorlevel 1 goto RUN

echo Copying Files...

rem XCOPY commands go here



If you find that XCOPY can't do what you want, look at pkzip 2.50 for DOS (free). Using it in your batch file you could:

1. Travel down through a directory and subdirectories, selectively zipping up files using a wildcard (e.g., *.doc). You would use an option to not save path information.

2. Then unzip that temporary zip file to the location of your choice -- i.e., the new location for *.doc files.

3. Delete the temp zip file. Or keep it -- it's a backup of the users' files, so you don't have to bug them to make a backup! :)