Link to home
Start Free TrialLog in
Avatar of elgin229
elgin229Flag 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
Avatar of Bill Prew
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
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There are also some small 3rd party tools as an alternative such as Lupus Rename
Avatar of 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