Windows 7 – How to Remove the First Character from All Filenames in a Folder

renamewindows 7

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.

Best Answer

again, try powershell ;)

Run this in your desired directory:

get-childitem *.txt | rename-item -newname { [string]($_.name).substring(1) }

Explanation:
- 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]($_.name).substring(1) takes the filename starting after the first character

Related Question