Basic Question:
How can I take a recently created folder (done in the same batch), then do stuff in the folder, then rename the folder with a timestamp and repeat with a new file generating a new timestamp?
My Batch Code Outline and Expected vs. Actual Results:
I am creating a batch file that will loop through the steps below, for all files in a directory.
Step 1 (working): go through file in a directory and extract data, this data will then be outputted into a created folder that has to be named "output" (which is created during this step).
Step 2 (working): I have to go into this "output" folder and "do stuff" with the data (I already have a script that goes into this new filepath of the "output" and "does stuff")
Step 3 (not working): rename the folder "output" to "output_TimeStamp" (This is where my problem is, my loop takes the timestamp#1 of the first folder created, and tries to name all folders timestamp#1)
Step 4 (semi working): Go back to Step 1 to work on the next file (Loop till all files are finished in directory)
My Code (well at least one of my attempts)
::Loop to perform tasks on files in current directory
for /R %%f in (*.mp4) do (
::Extracts data from file and leaves it in a created output folder
start "" /w Sample.exe --clip "%%f" --verbose 2 --outDir output
::This goes in created output folder and does stuff to data
start "" /w C:\Users\user\Documents\winPython\WinPython-64bit-3.4.4.2\python-3.4.4.amd64\python.exe "%CD%\DoStuff.py" "%CD%\output\folder\folder2\Do.file"
::This is supposed to rename the folder with a time stamp
rename output output-%date:~4,2%-%date:~7,2%-%date:~10,4%_at_%time:~0,2%%time:~3,2%
::This is what my research came to, which increments a number in the timestamp but doesnt work
set N=0
set FILENAME=output-%date:~4,2%-%date:~7,2%-%date:~10,4%_at_%time:~0,2%%time:~3,2%.%N%
:loop
set /a N+=1
set FILENAME=output-%date:~4,2%-%date:~7,2%-%date:~10,4%_at_%time:~0,2%%time:~3,2%.%N%
if exist %FILENAME% goto :loop
echo You can safely use this name %FILENAME% to create a new file
)
My Research
I have tried numerous things and used the links How do I increment a folder name using Windows batch?
and cmd line rename file with date and time.
I feel like this should be a lot easier then writing out this question.