I have more than one file in the folder with WXYZDT2 in the file name.
When I run the bat file it only picks up one of the files to rename (if I run it through a second time it picks up the next file).
Can someone point out the error.?
Set Hour=%Time:~-11,2%
Set Minute=%Time:~-8,2%
Set Second=%Time:~-5,2%
Set TodayTime=%Hour%-%Minute%-%Second%
for %%a in ("*WXYZDT2*.wtv") do call :newname "%%a"
if %%a not==("*WXYZDT2*.wtv") then goto finish
:newname
rename %1 ch7_%TodayTime%.wtv
:finish
+ Reply to Thread
Results 1 to 6 of 6
-
-
Name collision.
You're setting a constant value (the date-time string) and then trying to rename every file to the same value "ch7_(the value).wtv"
The first rename works, the others try to work but there's already a "ch7_(the value).wtv" file so they can't rename and skip. -
I thought the 'Seconds' ensure that the new names are different - I tried inserting 'Ping' values to cause a delay, but no effect.
Is it taking one instant of time and using that value for all the files?
Any suggestions? -
Indeed. But you have set your renaming outside the loop.
You may wish to repeat the first 4 lines just after ':newname' so the first rename catches the first 4 lines and the rest will work off the repeat. -
Thank you, I got it working - as long as it's from 10AM to Midnight - then it fails, probably because it tries to insert a space in the file name for hours that are a single digit?
Any suggestions? -
Update, I got it working for both one and two digit hours.
Thank you for the suggestions;it put me on the correct path.
for %%a in ("*WXYZDT2*.wtv") do call :newname "%%a"
if %%a not==("*WXYZDT2*.wtv") then goto :end
:newname
move %1 c:\agk_rename
cd\
c:
cd agk_rename
REN %1 "* %Date:/= % %Time::=.%.wtv"
echo processing "%~n1"
move *.wtv "e:\recorded tv"
cd\
e:
cd recorded tv
:end
Similar Threads
-
Help me join these two .bat files...
By CactusMan in forum Newbie / General discussionsReplies: 3Last Post: 18th Jan 2012, 13:08 -
Need a .bat file to join avi files
By aat666 in forum Newbie / General discussionsReplies: 2Last Post: 7th Oct 2010, 06:46 -
Help with these commands - VC1 ASF2VC1 .bat.....
By tigerb in forum Newbie / General discussionsReplies: 4Last Post: 2nd Feb 2010, 18:01 -
get FPS value from mediainfo into a bat script
By ricardouk in forum ProgrammingReplies: 1Last Post: 10th Nov 2009, 09:27 -
Problem using AVCHD_Convert *.bat files
By aghusker in forum Video ConversionReplies: 2Last Post: 17th Jul 2008, 20:46