Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to remove the first character (which is always "_") from all filenames in a folder.

I'm currently using this command: ren _*.txt *.txt But it doesn't work.

However, if I run ren _*.txt A*.txt it perfectly works, but it is not what I want.

share|improve this question
up vote 12 down vote accepted

again, try powershell ;)

Run this in your desired directory:

get-childitem *.txt | rename-item -newname { [string]($ }

- get-childitem *.txt collects all *.txt-files in the actual directory.
- rename-item -newname renames the piped results from the get-childitem command with the string that is generated in {}
- [string]($ takes the filename starting after the first character

share|improve this answer
hey, it says gci is not recognized as an internal or external command – Patrick Apr 20 '11 at 12:30
hm... this should work...however. gci is per default an alias for Get-Childitem - take that instead. Did you run powershell? It doesn't work if you tried that in cmd.exe (but you can start powershell.exe from within cmd) – wullxz Apr 20 '11 at 12:32
all right, now it works. I still have a small issue, the first character is actually a ".", so I have 2 initial characters to remove "._filename.jpg" and not "_filename.jpg". Do you how to deal with the dots ? – Patrick Apr 20 '11 at 12:40
if you want to remove the first 2 characters, just replace the (1) after 'substring' with (2). In powershell, the whole filename is treated as a string(-object), points included. – wullxz Apr 20 '11 at 12:43

If you want to avoid having to write anything, try the Bulk Rename Utility. The interface can be quite scary at first but just have a play around with it and you'll see it's not actually hard to use at all.

share|improve this answer

Just if anyone needs in future: I use 1-4 rename. It is fast, does not have to be installed. When you run it hit F2 for advanced mode and you can tell it to kill the first 4 characters. Below is the link to the program.

Download Link:

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .