Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Can anyone help me develop a script to rename files in the current directory in the following format based on when the original files were saved i.e.
Original file names
111-1175_IMG.JPG
111-1176_IMG.JPG
111-1177_IMG.JPG
...Too
04042003-01.JPG
04042003-02.JPG
04042003-03.JPG
...Thx
J

This should be posted over in the programming forum but I think that this should do the trick.
Dim strY, strM, strD, strDate, strFile, strOrig, strNew
Dim fs, f, f1, fc, s, strFolder, WshShell, fname, intCounton error resume next
' USER CONFIG AREA
dteData = now() 'Current Date
strfolder = "c:\test\" 'Folder
intCount = 0
strY = ltzero(Year(dteData)) 'Year
strM = ltzero(Month(dteData)) 'Month
strD = ltzero(Day(dteData)) 'DaystrFile = stry & strM & strD 'Filename
set fs = CreateObject("Scripting.FileSystemObject")
set f = fs.GetFolder(strfolder)
Set fc = f.filesFor Each f1 in fc
strOrig = strfolder & f1.name
intCount = intCount + 1
aryFile = Split(f1.name, ".", -1, 1)
strNew = strfolder & strFile & "-" & ltzero(intCount) & "." & aryFile(ubound(aryFile))
fs.movefile strOrig, strNew
Next
function ltzero(intVar)
if intVar 10 then
ltzero = "0" & intVar
else
ltzero = intvar
end if
end function

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |