Rename only first 2 characters

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
bmatt8
Posts: 1
Joined: 15 Oct 2018 12:54

Rename only first 2 characters

#1 Post by bmatt8 » 15 Oct 2018 12:58

I need to rename only the first 2 characters of a filename. What command would I use without using powershell/python/etc... Hopefully just use the REN command.

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: Rename only first 2 characters

#2 Post by dbenham » 15 Oct 2018 13:35

To set the first two characters of all files in the current directory to XX:

Code: Select all

ren *.* XX*
See How does the Windows RENAME command interpret wildcards? over at StackExchange SuperUser for an explanation as to why this works.


Dave Benham

Post Reply