Unsolved

This post is more than 5 years old

2 Posts

8060

May 26th, 2005 00:00

Writing a Batch file in Windows XP

I am running windows xp.  I have a folder titled DMEVI6 that resides on my E Drive.  Inside that folder are six subfolders.  I want to be able to go to the RUN menu and have a batch file run that will copy the DMEVI6 folder and all its subfolders to my D Drive.  How do I write the batch file?  I also want it to automatically overwrite a previous session.

2 Intern

 • 

11.9K Posts

May 26th, 2005 01:00



@zbmerman wrote:
I am running windows xp.  I have a folder titled DMEVI6 that resides on my E Drive.  Inside that folder are six subfolders.  I want to be able to go to the RUN menu and have a batch file run that will copy the DMEVI6 folder and all its subfolders to my D Drive.  How do I write the batch file?  I also want it to automatically overwrite a previous session.



Use Notepad to create a .BAT file.  Put in it the commands as follows:

e:

cd .\dmev16

copy *.* d:\dmev16

cd .\NAME OF SUBFOLDER

copy *.* d:\dmev16\NAME OF SUBFOLDER

and so on, switching back to the dmev16 directory then to a sub folder...

Then use Scheduled Tasks to run the folder when you want to.

I fixed a typo from *.8 to *.*.  Also, you should execute any proposed commands in Command Prompt, line by line, writing down EXACTLY what you do, to make sure each line works exactly as intended, then create the batch file, then verify it's outcome.

Message Edited by rickmktg on 05-26-2005 07:39 AM

Message Edited by rickmktg on 05-26-2005 09:32 AM

2 Intern

 • 

2.5K Posts

May 26th, 2005 03:00

WARNING there is an error in the above batch file.  the line

"copy *.8 d:\dmev16\NAME OF SUBFOLDER"

is incorrect it probably should be

copy *.* d:\dmev16\NAME OF SUBFOLDER

Even with my correction I am not sure the script if will work as desired.

Message Edited by msgale on 05-26-2005 01:48 AM

Message Edited by msgale on 05-26-2005 01:52 AM

4.4K Posts

May 26th, 2005 04:00

The section on the copy command in the XP command line reference should clear up any questions about the syntax of this command.

Jim

2 Intern

 • 

2.5K Posts

May 26th, 2005 09:00

The syntax is correct, one of the parameters is wrong, and the logic may be incorrect. 

2 Intern

 • 

11.9K Posts

May 26th, 2005 10:00



@msgale wrote:
The syntax is correct, one of the parameters is wrong, and the logic may be incorrect. 



Fixed the typo, what's wrong with the logic?  I use files like this all the time, just put one in yesterday on a machine that's copying partition M to D via Ghost, then copying the Ghost file to a DVD-RW after erasing the contents of the DVD.

Any file should be executed, line by line, in Command Prompt, to confirm the exact instructions.  I added that caveat to my post.

35 Posts

May 26th, 2005 12:00

Use Notepad to create a .BAT file. Put in it the commands as follows:
e:
cd .\dmev16
copy *. * d:\dmev16
cd .\NAME OF SUBFOLDER
copy *.* d:\dmev16\NAME OF SUBFOLDER
and so on, switching back to the dmev16 directory then to a sub folder...


i might be seeing things . . . but did i notice another incident of incorrect syntax . . . the blank space between the period and asterisk . . . and this was after rickmktg corrected the code ?

copy *. * d:\dmev16
should be :
copy *.* d:\dmev16

2 Intern

 • 

11.9K Posts

May 26th, 2005 12:00



@pijai wrote:
Use Notepad to create a .BAT file. Put in it the commands as follows:
e:
cd .\dmev16
copy *. * d:\dmev16
cd .\NAME OF SUBFOLDER
copy *.* d:\dmev16\NAME OF SUBFOLDER
and so on, switching back to the dmev16 directory then to a sub folder...


i might be seeing things . . . but did i notice another incident of incorrect syntax . . . the blank space between the period and asterisk . . . and this was after rickmktg corrected the code ?

copy *. * d:\dmev16
should be :
copy *.* d:\dmev16

et tu, Brute'?  :smileyvery-happy:

1.4K Posts

May 27th, 2005 01:00

Here's a simple one that will do all you want in one step (the folder and all sub-folders and all files).
Copy the text to Notepad and 'save as' to the desktop anyname.BAT :
 
E:
cd dmev16
xcopy /e /r /h /y E:\dmev16 d:\YourFolder
pause

Message Edited by chuket on 05-26-2005 11:00 PM

No Events found!

Top