Please Read: Significant Update Planned, Migrating Forum Software This Month

See more
See less

Batch File Problem

  • Filter
  • Time
  • Show
Clear All
new posts

  • Batch File Problem

    Since I started in IT when DOS was considered an advanced technology I am almost embarrassed to have to ask for help with this, but since I have little hair left I guess I will swallow my pride and put this out there.

    Without going into my normal painful detail; from a 2008 R2 server I need to automatically rename a directory on a mapped drive (Z: ) while adding the date to that folder and then create a new empty one with the same name as the original one I renamed. I am backing up folders from the server to the qb_copy folder.

    Here is what I have done so far but it fails at the rename function. I cannot figure out why. The variables work, the wait time works and the new directory creation works. Just the rename fails with a syntax error. When the batch file is finished I should have a populated folder named QB_Copy_For_07-20-2014 (as of today's date)

    for /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do set cdate=%%a-%%b-%%c

    set "var1=QB_Copy_For_"

    ren z:\qb_copy z:\%var1%%cdate%

    ping -n 1 -w 6000>NUL

    MD z:\"qb_copy

    What am I doing wrong?


  • #2
    Re: Batch File Problem

    Hello guys and gals,

    I feel stupid. I figured it out about 2 minutes after I posted it. The second Z: in the rename command line had to be removed... I had forgotten about that particular oddity.

    Thanks for reading. Hope I can help someone else.


    • #3
      Re: Batch File Problem

      Thanks for posting back with your solution.

      I can empathise TOTALLY with the technologically advanced DOS (v3.3) and the follically challenged aspect of your post. Hair today.......gone NOW!!
      1 1 was a racehorse.
      2 2 was 1 2.
      1 1 1 1 race 1 day,
      2 2 1 1 2