Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Renaming files

Hi!

I have 4000+ PDF files that I need to rename. All I need to do is add 2
zeroes to the beginning of the filename (a file named 3668_new_file.pdf
should be 003668_new_file.pdf). I don't know alot about VB, but I'm
sure there is a way to write some code to automate this. Any
suggestions?

Thank you!
Dana



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Renaming files

Dim sNames() as String, i as long, j as Long
Dim sPath as String, sName as String
Redim sNames(1 to 5000)
i = 1
sPath = "C:\My Documents"
sName = dir(sPath & "\" & "*.pdf")
Do while sName < ""
sNames(i) = sName
i = i + 1
sName = dir()
Loop
for j = 1 to i-1
name sPath & "\" & sName(j) as sPath & "\00" & sName(j)
Next

Others may suggest doing the renaming in the first loop - this can cause
problems because you are changing the directory within a loop using DIR.
There is an MS Knowledge Base article that warns against doing this as it
could cause problems.

--
Regards,
Tom Ogilvy



"Dana Wilson" wrote in message
...
Hi!

I have 4000+ PDF files that I need to rename. All I need to do is add 2
zeroes to the beginning of the filename (a file named 3668_new_file.pdf
should be 003668_new_file.pdf). I don't know alot about VB, but I'm
sure there is a way to write some code to automate this. Any
suggestions?

Thank you!
Dana



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Renaming files

Tom,

Thanks so much!!! It worked perfectly!! You saved me so much time!!

Dana



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Renaming excel files in a folder Rhett C[_2_] Excel Discussion (Misc queries) 1 January 29th 10 05:23 AM
Renaming Files w/Excel Confused VB Person Excel Discussion (Misc queries) 4 March 21st 08 09:26 AM
Batch renaming of many worksheets in Excel files? Lumen S Excel Discussion (Misc queries) 2 August 17th 06 09:48 PM
Renaming Files Bear Excel Discussion (Misc queries) 2 December 5th 05 09:02 PM
Renaming Files Spammastergrand Excel Programming 5 September 19th 03 10:43 PM


All times are GMT +1. The time now is 11:53 PM.

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

About Us

"It's about Microsoft Excel"