• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

How to change a bunch of filenames to remove some characters

Folder containing hundreds of mp3 files. Each file has a spurious bumber and space at the front of the filename which I need to remove.

Example 1: 07 some song or other.mp3
Example 2: 1-14 some other song.mp3

I thought I'd be able to do it at the command line using REN "07 *.mp3" *.mp3, but no dice

Any suggestions for how to do this from the command line?

Just to emphasise, I need to lose the space as well as the numbers at the front of the filename.

OS = Win7
0
richardbarlow
Asked:
richardbarlow
1 Solution
 
KGGCommented:
Select all
Right click
click on rename
and enter name for example - mymusic

It will rename all to mymusic01, mymusic02.....
0
 
harunyuvaCommented:
I am using "Better File Rename" software like your operation. it is so useful.  

http://www.publicspace.net/windows/BetterFileRename/index.html 
0
 
Steve KnightIT ConsultancyCommented:
From a command prompt you could construct a batch file as follows using notepad and save in the dir with the filenames:
@echo off
for /f "tokens=1* delims= " %%a in ('dir /a-d /b *.mp3') do echo rename "%%a %%b" "%%b"

This takes a dir listing in bare format (/b) of files only (/a-d) and then for each line in the file splits the line at the first space.  The bit before the space goes to %%a and the rest of the name and extension to %%b .

If the rename comands look right on the screen then remove the word echo to make it actually do the renames...

You can also do 'search and replace' using same technique to remove other parts of the filename such as 'DVDRip' or a tag name etc. if needed.  The batch gets a bit more complicated then having to use delayed expansion but can show if needed.

Steve
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Steve KnightIT ConsultancyCommented:
I should have said, if you want to run from a command prompt directly, rather than from a batch file just replace the %% with %, i.e.

for /f "tokens=1* delims= " %a in ('dir /a-d /b *.mp3') do rename "%a %b" "%b"

Of course if there are multiple files with the same name after first space then a rename will fail on those.  If that is possible we could carry out a check too..

Steve
0
 
richardbarlowAuthor Commented:
Excellent answer. Thank you
0
 
Steve KnightIT ConsultancyCommented:
No pblem, glad it helped.

Steve
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now