Avatar of elgin229
elgin229
Flag for United States of America asked on

Batch renaming files

Hello everyone,
In Windows 10. . . I need to remove the first 4 characters from about 250 file names.  They look like this: [ 005_this is a squirrel.jpg ].  I want it to read [ this is a squirrel.jpg ]

I can use CMD and I'm just starting with Powershell.

Thanks so much in advance.
elgin
PowershellWindows 10Windows BatchWindows OS

Avatar of undefined
Last Comment
elgin229

8/22/2022 - Mon
Bill Prew

Here's a small BAT script that you could try to get the job done.  It assumes all the JPG files in the current folder need to be renamed.  Save the BAT, CD to the folder with the files, and run the BAT.  It's in test mode, and will just echo the REN commands it would execute to the command console.  If you like what that look like remove the ECHO on the REN line and run for real.

@echo off
setlocal EnableDelayedExpansion

for %%A in ("%.jpg") do (
    set name=%%~nxA
    set name=!name:~4!
    ECHO ren "%%~A" "!name!"
)

Open in new window


»bp
ASKER CERTIFIED SOLUTION
oBdA

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Mike Sun

There are also some small 3rd party tools as an alternative such as Lupus Rename
elgin229

ASKER
I really appreciate these responses.  Because of my limited knowledge, I was able to get the answer from oBdA to work so I'm grateful for that, but also appreciative for the other responses.

I downloaded and installed the Lupus Rename program and was able to get the files renamed, but couldn't figure out how to actually save the changes.  I'm sure it's simple.

Nevertheless, I got the files renamed and I'm happy,

Thank you, gentlemen, for your assistance.

Kindly,
elgin
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes