How to make a batch file copy itself?

Copy files using batch file command?

  • Im looking to make a batch file that will copy files from a jump drive and place them in a folder on the computer. What command and syntax would I use? thanks

  • Answer:

    If all your files are one directory then just use the copy command. If you have multiple directories then you need to use xcopy or if you have Windows Vista or later then Robocopy is better. Xcopy and Robocopy has loads of choices depending on exactly what you want. To copy everything then you would use xcopy jumpdrive_letter:\ harddrive_letter:\directory\ /e robocopy jumpdrive_letter: harddrive_letter:\directory /e http://www.computerhope.com/copyhlp.htm http://www.computerhope.com/xcopyhlp.htm http://www.computerhope.com/robocopy.htm If you've got it then I would use robocopy. By default it only copies files if there is not an exact copy already in the destination drive which makes it great for backups.

Josh Bunzel at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Create a file xyz.bat which contains the following line: xcopy source destination /E You replace source with your drive symbol such as E: etc and destination drive or directory Then, type xyz at the command prompt while you are in the DOS mode. If XCOPY is available, why do you go for batch program?

James Bond

echo off SetLocal EnableDelayedExpansion for /f "tokens=1 skip=1" %%a in ('wmic bootconfig get lastdrive') do if "!Thumbdrive!"=="" set ThumbDrive=%%a xcopy /s !ThumbDrive!\*.* %SystemDrive%\Users\%username%\desktop This will copy all items in thumbdrive to your desktop.

Jake

put the batch file on the thumb drive copy *.* c:\backup just substitute your own location

Mike

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.