Copying single files into a folder that changes name every time the batch file is executed

Posted by Daniel Jochem on Super User See other posts from Super User or by Daniel Jochem
Published on 2012-04-07T07:15:54Z Indexed on 2012/04/07 11:36 UTC
Read the original article Hit count: 277

Filed under:
|
|
|

Can you please help, I am using this to put the text files made by the batch file into the folder created by the batch file as well. but my problem is that the name is changed of the new folder every time because it is named by the date and time it was created. This is the code:

@echo off

for /F " tokens=1,2,3* delims=/, " %%i IN ('date /T') DO (
set CUR_DAY_OF_WEEK=%%i
set CUR_MONTH=%%j
set CUR_DAY=%%k
set CUR_YEAR=%%l)

for /F " tokens=1,2,3* delims=:, " %%i IN ('time /T') DO (
set CUR_HOUR=%%i
set CUR_MIN=%%j
set AM_PM=%%k)

if not exist E:\Private goto :F
cd E:\Private
md "E:\Private\%CUR_HOUR%.%CUR_MIN%%AM_PM% %j%%CUR_MONTH%-%CUR_DAY%-%CUR_YEAR%"
goto :start

:F
if not exist F:\Private goto :G
cd F:\Private
md "F:\Private\%CUR_HOUR%.%CUR_MIN%%AM_PM% %j%%CUR_MONTH%-%CUR_DAY%-%CUR_YEAR%"
goto :start

:G
cd G:\Private
md "G:\Private\%CUR_HOUR%.%CUR_MIN%%AM_PM% %j%%CUR_MONTH%-%CUR_DAY%-%CUR_YEAR%"
goto :start

:start
start /min A /stext A.txt 
start /min B /stext B.txt
start /min C /stext C.txt
start /min D /stext D.txt

(As the directory (E:-G:) changes, how can I check all without an error? And once that is found, then put all these text files into the date folder.

© Super User or respective owner

Related posts about Windows

Related posts about copy