LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Rename Batch of Files in VBA

Darren,

Yes, the correct library is "Microsoft Scripting Runtime". Sorry
about that.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Darren Hill" wrote in message
...
That was quick :)

I don't appear to have a "Windows Scripting Runtime" in the

list, but I do
have a "Microsoft Scripting Runtime" - is that the one?

--
Darren
"Chip Pearson" wrote in message
...
Darren,

Here's some code to get you started. You'll need to go to

the
Tools menu in VBA, choose References, and set a reference to

the
Windows Scripting Runtime library.

Sub Start()

Dim FSO As Scripting.FileSystemObject
Dim TopFolder As Scripting.Folder

Set FSO = New Scripting.FileSystemObject
Set TopFolder = FSO.GetFolder("C:\FolderName") '<< CHANGE
ProcessOneFolder FSO, TopFolder

End Sub

Sub ProcessOneFolder(FSO As Scripting.FileSystemObject, _
F As Scripting.Folder)

Dim OneFolder As Scripting.Folder
Dim OneFile As Scripting.File

For Each OneFolder In F.SubFolders
ProcessOneFolder FSO, OneFolder
Next OneFolder
For Each OneFile In F.Files
Debug.Print OneFile.Name, OneFile.ParentFolder.Path,
OneFile.Path
Next OneFile

End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Darren Hill" wrote in message
...
I'm using Excel 2000.
I have a big macro to create - I don't expect the group to

do
all my work,
information on how to get started would be good for now.

My goal:
I have a directory ("C:\My Documents\Archive") which

contains
multiple
subdirectories, each of which contains files to be renamed.

Some
subdirectories also have their own subfolders.
Those files whose name starts with the string "File" needs

that
string
replaced with the folder name. If the file does not start

with
the string
"File", the immediate folder name gets added to the start

of
the folder
name.
The filelist will include non-Excel files.

I can do the string replacing bit, it's the creating a list

of
folders and
their content files, and then getting the immediate folder

and
using that to
rename the files that I have no idea about, and Google

isn't
helping much :)

Thank in advance.

Darren










 
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
How can I batch convert 97-2003 .xls files to 2007 .xlsx files Dave Nuttall Excel Discussion (Misc queries) 4 August 3rd 09 11:38 PM
Batch conversion of XP files to 97 files AG Excel Discussion (Misc queries) 2 October 2nd 05 02:08 PM
Can I batch rename new worksheets Harry Limey New Users to Excel 3 January 19th 05 09:19 PM
Batch Files Mitch[_2_] Excel Programming 4 October 4th 03 04:40 PM
Batch files and VBA daver676 Excel Programming 2 September 17th 03 06:57 PM


All times are GMT +1. The time now is 10:23 PM.

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

About Us

"It's about Microsoft Excel"