Move archive to Teams - need to delete folders and rename files

Amapola

New Member
Joined
Jul 7, 2010
Messages
17
Good Morning - I have been looking for snippets but this doesn't look as easy as I thought it should be! (VBA never is, isn't it!?!)

We are moving our archive to Teams and our company name is really long so the length of the path becomes too long and we won't be able to open a lot of files. Also, there's portion we don't need so my project is two steps.

Delete all folders and content with a specific path name
I need to loop through folders by year, through all subfolders and find the ones with a specific name (and it will always be the same name) and delete these folders with the contents.

Change File Names
The company policy has been to write the file names with " - " and you won't believe it, they write veritable novels here as file names. So I want to go through all file names and replace this with an underscore for starters.
If that is not enough to bring us across the line, I might to find specific files and adjust the file names. I have a macro that can pull all the file names and put them into a spreadsheet so I can count the lengths and assign a new name. That portion should be manageable so I will actually have a spreadsheet with name OLD in one column and name NEW in another.

If anybody has code that does one or the other, I would be really grateful. If I can't find code, I think I can get around the first by simply search for the folder name and delete them manually. Still a lot of work but not totally impossible like the second task!

Thank you!

Christine
Auckland, NZ
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi Christine.

Not an excel solution (although it would be possible to create one), but pointers to 2 utilities I use which would go a long way to what you want.

To do step 1 (deleting folders), you could use a utility called FileLocator Lite which is free for commercial use FileLocator Lite – Download – Mythicsoft. You would simply search from your root folder for the specific name to be deleted, and then just select all the results and hit Delete.

For step 2, you could replace all the - with underscore using this utilty called PFrank. Download PFrank 2.33. This utility is a renaming tool - you could simply use it to replace the - with underscore, but with a bit of thought and some agreed abbreviations, you could also use it to reduce the length of the filenames as well.

I hope this helps.
 
Upvote 0
Hi Christine.

Not an excel solution (although it would be possible to create one), but pointers to 2 utilities I use which would go a long way to what you want.

To do step 1 (deleting folders), you could use a utility called FileLocator Lite which is free for commercial use FileLocator Lite – Download – Mythicsoft. You would simply search from your root folder for the specific name to be deleted, and then just select all the results and hit Delete.

For step 2, you could replace all the - with underscore using this utilty called PFrank. Download PFrank 2.33. This utility is a renaming tool - you could simply use it to replace the - with underscore, but with a bit of thought and some agreed abbreviations, you could also use it to reduce the length of the filenames as well.

I hope this helps.
Thanks, jmacleary. We're pretty locked down from an IT side here. Hence VBA is still my preferred option. Somehow feel that it will take longer to get software approved than cobbling together a macro! - Thanks, Christien
 
Upvote 0

Forum statistics

Threads
1,212,927
Messages
6,110,696
Members
448,293
Latest member
jin kazuya

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