Batch File For Copying

Reply

  #1  
Old 11-16-09, 04:36 PM
Member
Thread Starter
Join Date: Mar 2002
Location: Ontario, Canada
Posts: 587
Received 0 Votes on 0 Posts
Batch File For Copying

I'd like to write a batch file to copy certain folders to a USB external drive. I think I can remember enough DOS to write the basic copy commands but since I won't know the destination drive letter until I plug it in, I need help with how to put an "Enter destination drive" command in the routine.

Anyone still speak DOS/BAT?
 
Sponsored Links
  #2  
Old 11-16-09, 06:41 PM
Member
Join Date: Sep 2009
Location: USA
Posts: 497
Received 0 Votes on 0 Posts
I grew up with DOS but like any language I'm getting rusty.

Anyways, try this. It used to be the CHOICE command but now in XP (don't have Vista or 7) it's called SET.

You can use this to copy files to existing folders as well. Whatever you put in for the prompt is where it will copy the files too.

___________________________________________
ECHO.
ECHO File Copy Utility
@ Echo off
rem *** the next line will clear any current variable ***
set choice=
rem *** this next line prompts for input and sets variable ***
set /p choice=Enter Destination Drive letter:
copy c:\test\*.* %choice%
___________________________________________
 
  #3  
Old 11-17-09, 09:21 AM
Member
Thread Starter
Join Date: Mar 2002
Location: Ontario, Canada
Posts: 587
Received 0 Votes on 0 Posts
That should work.

Thanks dan
 
  #4  
Old 11-22-09, 08:04 PM
Member
Join Date: Nov 2004
Location: USA
Posts: 973
Received 0 Votes on 0 Posts
Just a side note (since your question was answered): you may want to use Microsoft's free utility called Robocopy to do this. It is command line, and VERY much more powerful than copy or xcopy.

My favorite feature of robocopy is it's /MIR switch, which is great for backups as you can maintain a MIRror image of a folder in a backup location...first time, it grabs everything, from then on, just what's changed...careful though, if you delete from the source, it deletes from the destination.
 
  #5  
Old 11-23-09, 10:45 AM
Member
Thread Starter
Join Date: Mar 2002
Location: Ontario, Canada
Posts: 587
Received 0 Votes on 0 Posts
There can never be too many answers :-)

Thanks chirkware.
 
Reply

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Thread Tools
Search this Thread
 
Ask a Question
Question Title:
Description:
Your question will be posted in: