rename multiple files

matttclark

Board Regular
Joined
Jan 13, 2011
Messages
100
I regularly receive a bunch of database generated report files in a directory. Every report is named similarly using a text name telling the generic type with a date/time stamp afterwards. For instance one series might be "Production Report 20110713141955". Every report in that series will be "Production Report <date/time>" so no two are named exactly the same.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
Each separate file is a report for a different department. I have not been able to get the database folks to include the department name in the report title so I need to manually rename all of them. They are always in the same sequence, by that I mean the first date-timed report is always Department A17, the second date-time is always Department A18, etc. The date and time stamps are of course always different so I cannot use a fixed renaming macro.<o:p></o:p>
<o:p></o:p>
Is there a way using VBA to rename all files in a directory by going in sequence through the files in the directory, and renaming those against a list in excel until all are done?<o:p></o:p>
<o:p></o:p>
Thanks!<o:p></o:p>
matt
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
When reading this question, the Dir command in msdos comes to mind immediately:

http://www.computerhope.com/dirhlp.htm

This will give you a list in the order you want. Based on that list, you should do the renaming.

Wigi
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,159
Members
452,892
Latest member
yadavagiri

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top