A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Rename all files in directory with oldname plus date



 
 
Thread Tools Display Modes
  #1  
Old June 3rd, 2004, 05:03 PM
Eric Blitzer
external usenet poster
 
Posts: n/a
Default Rename all files in directory with oldname plus date

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



  #2  
Old June 3rd, 2004, 05:18 PM
Wayne Morgan
external usenet poster
 
Posts: n/a
Default Rename all files in directory with oldname plus date

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.

--
Wayne Morgan
Microsoft Access MVP


"Eric Blitzer" wrote in message
...
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?



  #3  
Old June 3rd, 2004, 05:28 PM
Wayne Morgan
external usenet poster
 
Posts: n/a
Default Rename all files in directory with oldname plus date

"yyymmdd")

Should be

"yyyymmdd")

--
Wayne Morgan
Microsoft Access MVP


  #4  
Old June 3rd, 2004, 05:52 PM
Eric Blitzer
external usenet poster
 
Posts: n/a
Default Rename all files in directory with oldname plus date

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


-----Original Message-----
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.

--
Wayne Morgan
Microsoft Access MVP


"Eric Blitzer" wrote

in message
...
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?



.

  #5  
Old June 3rd, 2004, 07:01 PM
Rick Brandt
external usenet poster
 
Posts: n/a
Default Rename all files in directory with oldname plus date

"Eric Blitzer" wrote in message
...
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\*.*")


--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:50 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.