vote up 5 vote down star
2

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?

flag

1  
Do you really mean dos, or the windows command prompt? – therefromhere Jul 30 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 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 at 5:40
windows command prompt is DOS, until it becomes cygwin. Which it should. :-P – jweede Aug 7 at 18:15

10 Answers

vote up 6 vote down check

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.

They 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.

link|flag
12  
Wow, that's some interface. Looks like it'd be happy in one of the Worst GUI threads. – Pauk Jul 30 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 at 23:38
1  
I concur, that is one of the worst UI's I've ever seen. – JohnFx Jul 31 at 18:46
Ah! where is my Cygwin, find, mv. Won't mind some AWK, grep, sed too. It will still feel comfortable. – nik Aug 7 at 17:24
2  
I saw that GUI and immediately thought "That would be much more user friendly as a console app" – Grant Aug 7 at 17:42
show 5 more comments
vote up 2 vote down

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

What I like is 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|flag
vote up 2 vote down

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|flag
+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 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 at 22:12
pipe would be | – John T Aug 7 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 at 17:28
Correct John T, I changed "pipe" to "redirect the output". Good catch. – WireGuy Aug 7 at 18:07
vote up 1 vote down

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|flag
vote up 0 vote down

The easiest way would be to use Rename Master.

link|flag
vote up 0 vote down

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|flag
vote up 0 vote down

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|flag
vote up 0 vote down

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|flag
vote up 0 vote down

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|flag
vote up 0 vote down

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|flag

Your Answer

Get an OpenID
or
never shown

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