How do I remove the same part of a file name for many files in Windows 7?

alt text

Basically, I have an album of music and I want to remove the authors name from all of the mp3 files instead of having to manually do it myself. Is there a function in Windows 7 Ultimate that can do this for me?

asked Jan 23, 2011 at 17:42 5,249 13 13 gold badges 41 41 silver badges 53 53 bronze badges

12 Answers 12

You could also try using PowerShell, a powerful Windows command line tool. You'd run this command:

Full Command:

get-childitem *.mp3 | foreach

Analyzing it:

get-childitem *.mp3
This lists all files whose names end with .mp3 . They are then piped to the next command with the | operator.

foreach < rename-item $_ $_.Name.Replace("Radiohead -", "") >
This replaces all instances of Radiohead - with nothing, denoted by "" , effectively wiping the word from all the files in the directory.

You could also modify get-childitem *.mp3 to get-childitem – that would rename all the files in the directory, not just files whose names end with .mp3 .

answered Apr 4, 2013 at 19:21 Zain Patel Zain Patel 2,820 1 1 gold badge 14 14 silver badges 17 17 bronze badges What does $_ $_. represent? Thanks! Commented Jul 18, 2016 at 15:52

@paulkon it represents whatever item was piped through from the previous command. In this case, it represents each item as they're yielded by foreach loop. The $_. follows the dot notation to access properties/methods/elements. So $_.Name accesses the Name property of each file that is piped through by get-childitem .

Commented Oct 26, 2016 at 23:51 for recursive rename, just add -recurse parameter to get-childitem Commented Oct 10, 2017 at 9:08

Thanks for this solution. worked a charm. I am sat here wondering how you get it to also modify files in sub-folders too? like how -R works on linux. I am a linux head.

Commented Nov 7, 2017 at 12:48

Don't forget to add -LiteralPath if you have things like square brackets in the name. Other than that tyvm for this answer! Upvoted

Commented Jun 22, 2018 at 19:41

Forget about complicated scripts for this.

rename is a very old and never properly completed command. If you do not use it properly, the result might surprise you.

For example to remove a prefix abcd from abcd1.txt , abcd2.txt , abcd3.txt etc. in order to get 1.txt , 2.txt , 3.txt simply use

rename "abcd*.txt" "////*.txt" 

You need the same number of / as the number of initial characters you would like to remove.

Do place double quotes for both arguments.

answered Jan 30, 2015 at 23:10 user414051 user414051

No particular rule. It is as it is. / can be a part of unc path so it is not the same as : < >|. It is probably treated as some sort of invisible path.

– user414051 Commented Dec 10, 2015 at 0:55 Very interesting and useful hack. Too bad it only works for prefixes! Commented May 15, 2017 at 22:42

Fantastic discovery. Very odd that both source and target must be quoted, else get The syntax of the command is incorrect error. I'm curious if this technique has ever been posted anywhere prior to this answer?. I need to update my How does the Windows RENAME command interpret wildcards? Q&A, though technically, the / are not functioning as wildcards.

Commented Jun 3, 2017 at 18:48

Doesn't remove '.' in the file names. eg., dbo.table1.sql, dbo.table2.sql, it renames them to .table1.sql, .table2.sql

Commented Jul 25, 2017 at 15:29

For the above comments, you have to use the * wildcard. This answer should absolutely be the correct one. This is much simpler and more powerful then any obtuse powershell or batch script.

Commented Aug 11, 2022 at 23:30

ReNamer can do that. In ReNamer, just add a 'remove' rule like this (a 'delete' rule will also work):

ReNamer 'remove' rule

And then drag and drop the files, or the folder containing the files you want renamed to its window (or use the 'Add Files/Folders' buttons), then check the preview, and once verified, click on 'Rename':

ReNamer window

answered Jan 14, 2014 at 2:17 galacticninja galacticninja 6,313 17 17 gold badges 81 81 silver badges 123 123 bronze badges

This might work.

Create a batch file as follows:

for %%i in ("*.mp3") do (set fname=%%i) & call :rename goto :eof :rename ::Cuts off 1st four chars, then appends prefix ren "%fname%" "my%fname:~4%" goto :eof 
answered Jan 23, 2011 at 18:30 user3463 user3463 Disclosure: my answer was edited, so it is no longer an exact copy of the comment I referenced. Commented Nov 19, 2013 at 21:24

Try this software

Bulk Rename Utility is a free file renaming software for Windows. Bulk Rename Utility allows you to easily rename files and entire folders based upon extremely flexible criteria. Add date/time stamps, replace numbers, insert text, convert case, add auto-numbers, process folders and sub-folders. plus a whole lot more! Rename multiple files quickly, according to many flexible criteria. Rename files in many ways: add, replace, insert text into file names. Convert case, add numbers. Remove or change file extensions. Check the detailed preview before renaming. Rename photos using EXIF meta data (i.e. "Date Picture Taken", "Resolution" and other information embedded in all JPG photo files) Rename your holiday pictures from a meaningless dsc1790.jpg to NewYork1.jpg in a flash. Rename MP3 files using ID3 tags (a.k.a. MP3 ID3 tag renaming). Change files' creation and modification time stamps. It's free. Easy to Install. Download and start renaming your files now!

answered Jan 23, 2011 at 18:48 58.5k 21 21 gold badges 115 115 silver badges 178 178 bronze badges

thanks. I saw this in google search but have to be careful with installing random software. given your rep and recommendation I installed it and it is incredible. No fiddling with powershell etc. I am a programmer and love the Trim, regex features. It works better than advertised. I highly recommend this too. ups!

Commented Mar 11, 2013 at 10:03

Since you are dealing with music files, forget about the batch file and utilities to rename your files. Use a dedicated program such as Mp3tag which is an absolute must if you're really into organizing your music.

Main features

Batch Tag Editing Write ID3v1.1, ID3v2.3, ID3v2.4, MP4, WMA, APEv2 Tags and Vorbis Comments to multiple files at once.

Support for Cover Art Download and add album covers to your files and make your library even more shiny.

Import from Amazon, discogs, freedb, MusicBrainz Save typing and import tags from online databases like Amazon, discogs, freedb, MusicBrainz, and more.

Replace characters or words Replace strings in tags and filenames (with support for Regular Expressions).

Create Playlists automatically Create and manage playlists automatically while editing.

Rename files from tags Rename files based on the tag information and import tags from filenames.

Export to HTML, RTF, CSV Generate nice reports and lists of your collection based on user-defined templates.

Full Unicode Support User-interface and tagging are fully Unicode compliant.

Besides these main features Mp3tag offers a variety of other functions and features ranging ranging from batch export of embedded album covers, over support for iTunes-specific tags like media type or TV Show settings, to combining multiple actions into groups that can be applied with a single mouse click.