How to omit characters at the beginning of a filename while renaming it in Windows cmd?

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 type

rename "abcd*.txt" "////*.txt"

You need the same number of / as the number of initial characters you would like to remove.

Do use double quotes for both arguments.

I copied the above from someone else on another thread.

Note that this handles filenames with space(s) correctly.


I faced a similar problem like this few months ago. It turned out removing characters at the beginning of file name is a little tricky using DOS. I came across this site which had a good solution for this.

All you need to do is cd into the directory containing the files and execute these two commands.

REN *.* " *.*" 
FOR %v IN (*.*) DO REN "%v" %v

This should replace the first character in all the file names.

The idea is to replace the number of unwanted characters with spaces using the first REN command then drop this spaces using the FOR loop and REN command.