Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
(1) I have 0,000s of digital pictures grouped in folders. I would like to append the date snapped to the front of the filename in the format in [ YYYYMMDD <sp> filename.ext ] format. (2) I would then like to remove any characters before the picture sequence so the filename would read [ YYYYMMDD nnnn.ext ]. (3) Typical filenames I would like to change would be IMG_3036.jpg, IMG_3037.jpg renamed to 20090621 3036.jpg, 20090621 3037.jpg.

I think you'd be better off taking the files you wish and put them in a file by name and date. Then use rename and for next to use list to perform. Be sure to be in correct path.
like
dir > file.txt (use options to get your date format if you can otherwise need one more step)
Then for 1 to what ever do rename until end.
There are plenty of ways to write batch files.
"Best Practices", Event viewer, host file, perfmon, antivirus, anti-spyware, Live CD's, backups, are in my top 10

here's a vbscript you can use
Set objFS = CreateObject("Scripting.FileSystemObject") strFolder = "c:\test" Set objFolder = objFS.GetFolder(strFolder) today=Now strYear=Year(Today) strMth=Month(Today) strDay=Day(Today) If Len(strMth) = 1 Then strMth="0"&strMth End If If Len(strDay) = 1 Then strDay="0"&strDay End If strDate = strYear & strMth & strDay For Each strFile In objFolder.Files strFileName = strFile.Name If InStr(strFileName,"IMG_") > 0 Then strFile.Name = Replace(strFileName,"IMG_", strDate & " ") End If Nextsave as myrename.vbs and on command line
c:\test> cscript /nologo myrename.vbs

I made an alternative solution using a bat (nt script).
Save the code (below) with a .bat entension. Ex: convert.bat
And run it. I have already tested and it worked fine.@echo off
setLocal EnableDelayedExpansion
for /f "tokens=1-4 delims=/ " %%d in ('date /t') do set dat=%%g%%f%%e
for %%a in (*.jpg) do call :subst "%%a"
goto end
:subst
for %%a in (%1) do (
set y=%%a
set y=!y:~1,4!
if !y!==IMG_ (
set x=%%a
set x=!x:IMG_=-!
set x="!dat!!x!"
rename %%a !x!
)
)
:end

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |