up vote 14 down vote favorite
5
share [g+] share [fb]

I've got a bunch of files named with a the pattern 99 - DescriptiveName.txt and I'd like to remove the number from the front so I just have DescriptiveName.txt.

How can I do this? Can I do it from the command line or is there a utility that can do this?

link|improve this question

2  
Do you really mean dos, or the windows command prompt? – therefromhere Jul 30 '09 at 20:52
Is DOS or Windows Command Prompt a requirement, or are you wondering if that is the best way? – Jim McKeeth Jul 30 '09 at 21:00
no, I'm just assuming there's a way I could do it in dos, because I can't imagine a way to do it in the GUI (btw. as far as I care, the windows command prompt is dos). – CodeSlave Jul 31 '09 at 5:40
windows command prompt is DOS, until it becomes cygwin. Which it should. :-P – jweede Aug 7 '09 at 18:15
feedback

13 Answers

up vote 16 down vote accepted

I know in your title you say "in dos" but I get the impression you are just looking for a way to do this and are wondering if that is the best way.

The absolute best tool I have found for this is Bulk Rename Utility.

Bulk Rename Utility

It isn't a command line tool, but they do have a command line version if you really want to use it that way.

I've used the GUI version a lot, and it is very powerful, very fast and extremely easy to use.

Oh, and it is FREE (Latest update includes non-intrusive ads and an option to pay and remove them.)

link|improve this answer
20  
Wow, that's some interface. Looks like it'd be happy in one of the Worst GUI threads. – Pauk Jul 30 '09 at 22:22
1  
@Pauk: It is a busy looking UI, but when you use it you discover everything you need is right there. A good example of how the usual principles don't always apply. – Jim McKeeth Jul 30 '09 at 23:38
2  
I concur, that is one of the worst UI's I've ever seen. – JohnFx Jul 31 '09 at 18:46
3  
I saw that GUI and immediately thought "That would be much more user friendly as a console app" – Grant Aug 7 '09 at 17:42
3  
I figured this is the UI equivalent of a regular expression. It looks terrible, but it gets the job done. – Jim McKeeth Aug 9 '09 at 2:50
show 7 more comments
feedback

AntRenamer does a pretty good job (with a GUI).

I like that it's quite easy to define a pattern of renaming; there are plenty of ones already prepared (and it gives a preview of the actions):

AntRenamer

link|improve this answer
feedback

If you really want to use the windows command line (if you don't want to download something), you could do it like this:

dir /B > fileList.txt
for /f "tokens=1,2,3" %i in (fileList.txt) DO ren "%i %j %l" %l

The first line outputs the list of files into a file called fileList.txt. The second line separates each of the names in the list into 3 parts, the #, the "-" and the rest of the name. For each of those it does the rename command.

link|improve this answer
feedback

old school:

You can do a DIR and redirect the output to a file, as in DIR *.TXT >TEMP.BAT

Then use an editor to take out what you don't need and modify the parts you do need. Add an "@echo off" as the top line, save it and run it.

link|improve this answer
1  
+1 If you don't need to do this on a regular basis, this is cool. I didn't even think of that! – EvilChookie Jul 30 '09 at 21:54
Thanks! Like I said, old school. But flexible. IBM VM/CMS had (or is it has) a DIR command called LISTFILE which took a parameter of (EXEC, it created their equivalent of a BAT file called an EXEC file, and prefixed each line with &1 &2. These were the first and second arguments to the EXEC file. You could then call you file and pass in a parameter of what you wanted to do, example ERASE. Very powerful. – WireGuy Jul 30 '09 at 22:12
pipe would be | – John T Aug 7 '09 at 17:11
I got this page reference from an old-school doctorate in this: dostips.com/DosCommandIndex.htm; It is amazing what you can do with (good?) old DOS! – nik Aug 7 '09 at 17:28
Correct John T, I changed "pipe" to "redirect the output". Good catch. – WireGuy Aug 7 '09 at 18:07
feedback

A small PowerShell script:

$args | ForEach-Object { Rename-Item $_ -NewName ($_.Name.ToLower() -replace ' ','-' )
link|improve this answer
feedback

I've used Free Commander Portable (freeware) for this to good effect:

  1. Select or Navigate to the files or directories to rename
  2. Press [Ctrl-M] (or File > Multi-rename)
  3. fill out the fields as makes sense for your circumstance
  4. verify the preview shows what you expect
  5. Go!
link|improve this answer
feedback

The easiest way would be to use Rename Master.

link|improve this answer
feedback

The tool that I've been satisfied with is ReNamer. It supports also the saving of renaming rules, which has been useful to me, as I many times do the same renamings.

link|improve this answer
feedback

Here's a command-line solution --- a Java program I wrote specifically to make it easy to work with "patterns" in filenames. It's free and open source, so feel free to modify it:

RenameWand
http://renamewand.sourceforge.net/

Some relevant usage examples:

Drop everything before the "-" in the filename:

java -jar RenameWand.jar  "<a> - <b>"  "<b>"

Prepend a 3-digit number to the filename, sorting by last-modified time:

java -jar RenameWand.jar  "<a>"  "<3|#FT> <a>"

Rearrange parts of the filename, and change case:

java -jar RenameWand.jar  "<album> - <artist> - <song>.<ext>" 
                          "<artist.upper> <album.title> - <song>.<ext.lower>"
link|improve this answer
feedback

I use Total Commander's multi-rename tool (ctrl+M) for things like this. Their useful tool, one of too many to count, is easy to use, and can also employ regular expressions and templates if necessary. Oh, and it obviously gives you a preview before making any changes.

This is the third or fourth question I've answered recommending Total Commander... I should be getting a commission from them ;-)

link|improve this answer
feedback

I discovered RenPhoric about a month ago. Superb. And it's free.

No complicated interface and I was quickly able to rename exactly as I wanted. Regular Expression capable. Haven't used anything else since.

link|improve this answer
feedback

Bulk Rename is my favorite

link|improve this answer
feedback

I like Cylog’s WildRename. It is powerful, yet easy to use, and has a lot of features:

  1. fast
  2. string manipulation
  3. counters
  4. wildcards
  5. regular expressions
  6. substitution
  7. case-conversion
  8. logging
  9. simulation (show the results without actually applying them)

enter image description here

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.