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

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

mole999

Well-known Member
Joined
Oct 23, 2004
Messages
10,524
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
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,195,644
Messages
6,010,893
Members
441,571
Latest member
stolenweasel

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
Top