How can I remove the first character from all filenames in a folder?
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
Forget about complicated scripts for this.
rename
is a very old and never properly completed command.
If you do not use it properly, the result might surprise you.
For example to remove a prefix abcd from abcd1.txt, abcd2.txt, abcd3.txt etc. in order to get 1.txt, 2.txt, 3.txt simply use
rename "abcd*.txt" "////*.txt"
You need the same number of / as the number of initial characters you would like to remove. So, for your specific situation, you would use
ren "_*.txt" "/*.txt"
Do use double quotes for both arguments.
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.