I would like a DOS-based batch script that takes all files within the current directory and renames them with the current date in YYYYMMDD-[Sequence Number padded to 3 digits]- and changes the extension to scr as follows:
alpha.txt becomes 20090723-001-.scr
beta.txt becomes 20090723-002-.scr
charlie.txt becomes 20090723-003-.scr
...
For the sequence increment, I have this but it's stripping off leading zeroes, (making it useless until I reach the 100th file):
set S=001
for %%F in (*.TXT) do (
set /A S += 1
ren "%%F" !S!%%~xF
)
/Edit:
The delim command can be used to hard code the century, and then parse the computer date for the date portion of the filename.
for /f "tokens=1-9 delims=/ " %%d in ("%date%") do rename "*.txt" 20%%f%%d%%e-###-.scr
The solution doesn't have to be pretty. It just needs to function.
alpha.txt becomes 20090723-001-.scr
beta.txt becomes 20090723-002-.scr
charlie.txt becomes 20090723-003-.scr
...
For the sequence increment, I have this but it's stripping off leading zeroes, (making it useless until I reach the 100th file):
set S=001
for %%F in (*.TXT) do (
set /A S += 1
ren "%%F" !S!%%~xF
)
/Edit:
The delim command can be used to hard code the century, and then parse the computer date for the date portion of the filename.
for /f "tokens=1-9 delims=/ " %%d in ("%date%") do rename "*.txt" 20%%f%%d%%e-###-.scr
The solution doesn't have to be pretty. It just needs to function.
Last edited: