Jump to content

CMD script for USB backup sequence

Go to solution Solved by Tea-Sir,

Consider the problem solved.

Got a little somewhere else.

 

The script problem that I needed solved was solved by these lines of code:

set counter=0

:backup

set /a counter=%counter%+1

md backup%counter%

 

From there all my commands to copy the files and eject the USB as well as restarting the process.

Hi

I am not sure if this is the right forum for this, but here goes.

 

I have a workflow at work that I would like to automate with Windows scripting CMD. We have a lot of USB drives that we use in short stints. After use, I make a backup and they go away until we need them again.

I already have a CMD script for deleting, formatting and copying template files. So all I really need is a little help in creating a backup of them. Now copying the files is not the issue. The issue is, that the people using the USB drives doesn't always rename the template files, even thoguh they are told to. So my backup strategy needs to take that into consideration and avoid overwriting files with the same name.

 

So the question:

Can I with a script do the following:

  1. Create a folder (Like backup1)
  2. Copy the contents of the USB drive into that folder
  3. Redo, these two steps, without any other interaction than switching USB drives? (So the next backup I make is called backup2), and if the only step is to hit the spacebar when the next USB drive is in, that is obviously fine :-)

Any name or number for the folders will do. It just needs to accomodate approx. 80 USB drives.

I also already have a program that ejects the USB drive.

 

If at all possible a copy command that will just add a number to a file that already exists will also be fine. File management is not important. Indexed search finds anything, if I need to.

 

Any help in doing this is appreciated.

 

Glenn

Link to comment
https://linustechtips.com/topic/1059260-cmd-script-for-usb-backup-sequence/
Share on other sites

Link to post
Share on other sites

Consider the problem solved.

Got a little somewhere else.

 

The script problem that I needed solved was solved by these lines of code:

set counter=0

:backup

set /a counter=%counter%+1

md backup%counter%

 

From there all my commands to copy the files and eject the USB as well as restarting the process.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×