Rename all files in directory with oldname plus date

  • Thread starter Thread starter Eric Blitzer
  • Start date Start date
E

Eric Blitzer

I have a specified directory where I want to rename the
files with the old name plus the date. I want to do this
with one click of a command button on a form. The number
of files changes anywhere from 1 to 100. Does anyone know
the code that will loop through all the files?

Thanks for your help


Eric
 
Successive calls to Dir without any parameters will continue to call the
next file meeting the original parameter. Do this until Dir returns "".

strFileName = Dir "<path>\*.*"
Do Until strFileName = ""
Name "<path>\" & strFileName As "<path>\" & strFileName & Format(Date,
"yyymmdd")
strFileName = Dir
Loop

Replace <path> with the actual path to the folder.
 
Thanks Wayne but I am getting a syntax error on the first line

strFileName = Dir "c:\newfiles\*.*"

Do I have this right

Thanks again
Eric
 
Eric Blitzer said:
Thanks Wayne but I am getting a syntax error on the first line

strFileName = Dir "c:\newfiles\*.*"

Do I have this right


strFileName = Dir("c:\newfiles\*.*")
 
Back
Top