@echo off
cd "%1"
set name="%3"
@For /F "tokens=1,2,3 delims=/ " %%A in ('Date /t') do @(
Set Day=%%A
Set Month=%%B
Set Year=%%C
Set All=%%C-%%B-%%A
)
ren "%1" "%All% - %name%"
@echo off
cd %1
set name=%3
set name=%name:"=%
echo %DATE% %TIME%
for /F "tokens=1-3 delims=/" %%a in ("%DATE%") do set DAY=%%a& set MTH=%%b& set YR=%%c
for /F "tokens=1-3 delims=:." %%a in ("%TIME%") do set HR=%%a& set MIN=%%b& set SEC=%%c
if "%HR:~0,1%"==" " set HR=0%HR:~1,1%
set MYDATE=%YR%%MTH%%DAY%-%HR%%MIN%%SEC%
set NEWNAME=%MYDATE%_%3
ren %1 %NEWNAME%
I love the idea of this script, however, I've tried both versions. I'm getting the following error: The syntax of the command is incorrect. Is there anything else you can think of that I might need to change?
I was running the code with echo on to try and see what was wrong and found it was adding a space instead of a 0 when it was midnight...also added a ping in to create a 2 second pause in case there was permission locking.
cd "%1"
set name="%3"
set name=%name:"=%
echo %DATE% %TIME%
for /F "tokens=1-3 delims=/" %%a in ("%DATE%") do set DAY=%%a& set MTH=%%b& set YR=%%c
for /F "tokens=1-3 delims=:." %%a in ("%TIME%") do set HR=%%a& set MIN=%%b& set SEC=%%c
IF "%HR:~0,1%" == " " SET HR=0%HR:~1,1%
set MYDATE=%YR%%MTH%%DAY%-%HR%%MIN%%SEC%
set NEWNAME=%MYDATE%_%3
ping 127.0.0.1 -n 2
rename %1 %NEWNAME%
I have been trying to get this functionality as well but I am clueless about scripts...I've tried to run this one and I also get the "syntax of the command is incorrect" error...any ideas on how I can get it to work? Thanks!
After reading, learning and tweaking I finally figured out I was getting the syntax error because %DATE% returned a different format on my system "Thu 04/24/2014" which resulted in the DAY being read as Thu 04 and consequently the rename command was trying to specify a target name with a space in it, minus the requisite quotation marks. I did some tinkering and came up with the following script which is working perfectly and renames the extracted folder exactly the same as Newsbin does: DD-MM-YYYY HHMM - FILE NAME. Thanks for the original script!
@echo off
cd %1
set name=%3
set name=%name:"=%
echo %DATE% %TIME%
for /F "tokens=1-5 delims=/ " %%a in ("%DATE%") do set DAY=%%c& set MTH=%%b& set YR=%%d
for /F "tokens=1-3 delims=:." %%a in ("%TIME%") do set HR=%%a& set MIN=%%b&
if "%HR:~0,1%"==" " set HR=0%HR:~1,1%
set MYDATE=%MTH%-%DAY%-%YR% %HR%%MIN%
set NEWNAME=%MYDATE% - %3
ren %1 "%NEWNAME%"