Renaming Files in Folder from "Name yyyy_MM_dd_hhmmss" to "Name yyyyMMdd"

rubyinfusive

New Member
Joined
Jun 12, 2015
Messages
3
Using Excel 2007
I receive a daily data dump in a specific file directory that has a time stamp in the form of "Name yyyy_MM_dd_hhmmss.csv"
Because the timestamp is not consistent, I am struggling to create a macro that can pickup the correct file from the folder.

Is there a macro that i can create that will rename "Name yyyy_MM_dd_hhmmss" to "Name yyyyMMdd"

In fact, if VBA can understand the format "Name yyyy_MM_dd" I'd be happy to just have "_hhmmss" deleted.

Alternatively, if there is a way to create a macro that can just look for "Name yyyy_MM_dd" and ignore that the timestamp, that would also be fine.

Currently I am using VBA to reference a date in my workbook in order to import the correct csv and I just need to find a way to do that for a file that contains a file name with a constantly changing timestamp.
e.g. Workbooks.Open FileName:= _
"\\Name " & Format(Sheets("test").Range("K3").Value, "yyyymmdd") & ".csv"

Many thanks!
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
do a web search for the freeware programme bulk file renamer (don't download from suspect sites) you will easily remove those I believe
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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