UNSOLVED

shelquis

updated

11 years ago

S

shelquis

2 Intern

•

219 Posts

0

22000

May 24th, 2015 08:00

Need Help Creating a Batch File

I'd like to create a batch file that I can have run by Task Scheduler. I'd like the batch file to create a new directory named with the current date in my F: drive and then to move a directory into the newly created directory. I'm hoping maybe there are batch file resources somewhere that might already have something like this created. Would appreciate any suggestions. Thanks.

  • theflash1932

    11 Legend

    •

    16255 Posts

    721

    0

    Posted May 24th, 2015 13:00

    The requirements are kind of obscure, so it is unlikely you'll find an existing script that will do just what you want ... you'll need to do some altering. Can I ask what it is you are trying to accomplish? Perhaps there is a better way to do it.

  • theflash1932

    11 Legend

    •

    16255 Posts

    721

    0

    Posted May 24th, 2015 13:00

    It's just that you said you were hoping something like this already was out there ... I was just saying that your requirements are not typical or common enough for there to be something out there that you could just download or copy and use. I can put something together for you, but what are you doing this for? What is your goal?

  • shelquis

    2 Intern

    •

    219 Posts

    721

    0

    Posted May 24th, 2015 13:00

    Thanks Flash. You say "The requirements are kind of obscure....... Since I'm not as computer fluent as perhaps I should be, I thought I outlined what I want pretty well. Please be more specific about what's missing. Summary:

    • Want the batch file to be activated via Task Scheduler
    • Want the batch file to create new directory on F: Drive with current date as the name
    • Want the batch file to move a Folder into the newly created Folder.

    I'll try to be more specific if you tell me what I've missed. Thanks.

  • shelquis

    2 Intern

    •

    219 Posts

    723

    0

    Posted May 24th, 2015 14:00

    Flash, you've really got me struggling. I'm not trying to be disrespectful, but I've listed my objectives twice. I'm not sure what more you're looking for. It seems straightforward to me.

    Background:

    Every Sunday night I make a system image backup. After the backup is complete I move the image into a new Folder with the date as its name. I want to automate all that by creating a batch file and scheduling it to run each week after the system image is recorded. I don't think I've said anything different here. What do you need? How can I say it differently.

    My problem with creating the batch file is naming the new Directory with the current date. Can you tell me how I can do that?

  • shelquis

    2 Intern

    •

    219 Posts

    723

    0

    Posted May 26th, 2015 14:00

    Flash, any ideas or suggestions for me. Thanks.

  • theflash1932

    11 Legend

    •

    16255 Posts

    723

    0

    Posted May 27th, 2015 23:00

    Yes, that helps. You are trying to bypass the limitation of Windows Backup to give yourself more than one image backup to refer to. You can manage multiple backup images more easily through Task Scheduler to pretty much any schedule you like using the following command:

    wbadmin start backup -backupTarget:\\SYSTEMNAME\DRIVELETTER$\FOLDER -include:C: -allCritical -quiet

    If you really want to use a BAT file, you can assign the folder name as the current date using the following:

    SET minnie=%date:~-10,2%%date:~-7,2%%date:~-4,4%
    md E:\%minnie%

    That will turn the current date into a string like 05272015 and create a folder using that string (E:\05272015 in this case).

  • shelquis

    2 Intern

    •

    219 Posts

    723

    0

    Posted May 28th, 2015 19:00

    Flash, thanks for the reply. As usual, I need more help. You say 

    .......................................... You can manage multiple backup images more easily through Task Scheduler to pretty much any schedule you like using the following command:

    wbadmin start backup -backupTarget:\\SYSTEMNAME\DRIVELETTER$\FOLDER -include:C: -allCritical -quiet

    • For SYSTEMNAME, do I use Computer name that shows up on Control Panel\System and Security\System?
    • Where do I enter this command? I don't understand how this command relates to Task Scheduler.
    • Would appreciate it if you could elaborate.

    Thanks.

  • theflash1932

    11 Legend

    •

    16255 Posts

    723

    0

    Posted May 28th, 2015 22:00

    You could put this in your batch file, then schedule your batch file to fire it off, but it's easier to just schedule the command itself. This can also be run on demand from an elevated command prompt.

    SYSTEMNAME is the name of your computer - the name found on the System information page.

    So, if the name of your computer is BOB-PC, you are saving the backups to the X: drive, in the Monday folder, your command would look like this:

    wbadmin start backup -backupTarget:\\BOB-PC\X$\Monday -include:C: -allCritical -quiet

    You enter this command on the Actions tab of the Task Scheduler in two parts:

    wbadmin goes in the Program/Script section:
    C:\Windows\System32\wbadmin.exe

    The rest of it goes in the Add Arguments section:
    start backup -backupTarget:\\BOB-PC\X$\Monday -include:C: -allCritical -quiet

  • shelquis

    2 Intern

    •

    219 Posts

    723

    0

    Posted May 29th, 2015 10:00

    OK, thanks Flash. That was the level of detail I need. Now, for the Folder. In your example, did that command create Monday, and send the image to it? Or did I have to have a folder named Monday already there?

  • theflash1932

    11 Legend

    •

    16255 Posts

    176

    0

    Posted May 29th, 2015 13:00

    No, the folder already existed. It will not create the folder if it doesn't exist.