Jump to content

Batch Programming Problem


Recommended Posts

I need to move xml files from folderA to folderB. Before the are moved to folderB I need to create a subfolder in B that is named according to system date and time. I have the code to move the files from folderA to folderB:

move /y C:\folderA\*.xml C:\folderB\

I have the code that creates a new folder and names it according to system time stamp of year,month,day_hours,minutes,seconds:

REM Create sub directory called \yymmdd_hhmmss

REM where yymmdd_hhmmss is a date_time stamp like 030902_134200


set hh=%time:~0,2%


REM Since there is no leading zero for times before 10 am, have to put in

REM a zero when this is run before 10 am.


if "%time:~0,1%"==" " set hh=0%hh:~1,1%

set yymmdd_hhmmss=%date:~12,2%%date:~4,2%%date:~7,2%_%hh%%time:~3,2%%time:~6,2%

md D:\batch-programming\%yymmdd_hhmmss%

how do I marry the two? I need to move the file to the newly created subfolder named from timestamp in folderB.

Link to comment
Share on other sites

I managed to solve the problem myself. I completely overlooked the fact that the lines that create the new folder stores the name(date time stamp) in a variable. You can then just call this variable or use it in your path where you are moving the files to.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.