VBA code to replace specific text in filename of specific filetype only in all subfolders

gtaksa

New Member
Joined
Sep 3, 2021
Messages
2
Office Version
  1. 2010
I've been searching for about an hour and cannot figure this out. I am not a programmer and don't know anything about VBA other than I have found some VBA code to do certain things where I can simply copy it and paste it and figure out how to change a specific file name or file path to do it with my files. I do accounting (but this is a personal need for djing/music collection) and while I might consider myself somewhat strong in excel for that because I can use INDEX/MATCH/MATCH and nested if formulas or google how to do certain things in excel itself - in reality I am so far from what some people can do with VBA. The extent is that I know this will use the Replace function and probably asterisks to find filenames that contain what I want to replace. So I hope someone will help provide me code specific to the filepaths and type I provide below:

I want to find all .mp3 filenames that contain "-mkd" and remove that portion of the filename, so replace with blank "". There are other file types that have "-mkd" in the name that I do not want to change - only the mp3 files. There are also files of all types that may contain two dashes "--" where I want only one dash "-". I want to do this in all subfolders of the path shown below.

E:\My Music\!Drum & Bass!\DnB - 2021 Archive\09-September

I will update the VBA code each month for the subsequent months files.

Thank you to anyone willing to help. I've also attached an image to provide more context. Each subfolder is a release... either a single or an EP. There are pictures, playlist, and info files that I want to leave alone unless they have two dashes "--" and only want to remove "-mkd" from the mp3 files.
 

Attachments

  • MP3 Rename.png
    MP3 Rename.png
    119.5 KB · Views: 23

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
@gtaksa
Welcome to the Forum
Instead of vba, I suggest you use a software like:
it's free for personal use.
The reason:
1. It's easier to use.
2. You can check the new filename beforehand.
2. It has undo function, in case something wrong happen.
 
Upvote 0
Solution
@gtaksa
Welcome to the Forum
Instead of vba, I suggest you use a software like:
it's free for personal use.
The reason:
1. It's easier to use.
2. You can check the new filename beforehand.
2. It has undo function, in case something wrong happen.
This works quite well, thank you - but I'm not finding any functionality to select only certain file types. It generates a list that allows me to subsequently check or uncheck the files that will be renamed. It's much better than manual, that's for sure.
 
Upvote 0
but I'm not finding any functionality to select only certain file types.

to select only mp3:
Click Add > Directories > choose the intended folder > Check Include subfolder > in Mask type *.mp3
renamer mp3.jpg
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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