Renaming files in a directory

G

Guest

In a spreadsheet called FileList I have a list of files in Col A like this:

C:\Documents and Settings\##My Documents\My Things\Blah Blah
Blah\Folder_2\01 Filename

In Col B I have the new file names like this:

C:\Documents and Settings\##My Documents\My Things\Blah Blah
Blah\Folder_2\01 New Filename

I want to replace all the file names in Col A with the new file names in Col
B so the file name in A2 would be replaced by B2 etc.

How do I make my macro Name OldFileName as NewFileName through each row in
the 2 lists?

Any help would be much appreciated

Many thanks

Kewa
 
R

Ron de Bruin

Hi Kewa

The basic code looks like this
Maybe it is better to test if the file in A exist before you rename it ?


For Each cell In Columns("A").SpecialCells(xlCellTypeConstants)
Name cell.Value As cell.Offset(0,1).Value
Next cell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top