Need to edit thousands of file names.

Hello,

I have a job where the provider mis-named appx 50,000 .jpg images.

They are currently named as such: IMG_2011_05_SYSTEM_FIVE_00001.jpg, IMG_2011_15_SYSTEM_FIVE_00002.jpg, etc...

and I need them all named without the "_SYSTEM_FIVE" like: IMG_2011_00001.jpg, IMG_2011_00002.jpg, etc... They would continue on as 00003, 00004, 00005, all the way up to ~50000.

I know how to use ren to change a name or add characters, but I can't figure out how to remove characters from the name,

Anyone know how?

Thanks!
funkyjoe1Asked:
Who is Participating?
 
Bill PrewConnect With a Mentor Commented:
Not sure if I understood the requirement or not.  You said:

==> I need them all named without the "_SYSTEM_FIVE"

but in your example

IMG_2011_05_SYSTEM_FIVE_00001.jpg

became

IMG_2011_00001.jpg

Here's a simple BAT script to just remove the original string you mentioned.  Save as a BAT file and adjust the SET of the folder where the files live.  Not that right now it will just ECHO the REN command it would execute to the screen.  If these look like what you need then remove the ECHO on the REN command and run for real.

@echo off
setlocal EnableDelayedExpansion
set BaseDir=c:\temp
for %%A in ("%BaseDir%\*.jpg") do (
  set OldName=%%~nA
  set NewName=!OldName:_SYSTEM_FIVE=!
  ECHO ren "%%~A" "!NewName!.jpg"
)

Open in new window

~bp
0
 
Bill PrewCommented:
Are they all in the same folder?

~bp
0
 
funkyjoe1Author Commented:
Hi Bill,

Thanks for the help.

Yes "_SYSTEM_FIVE" is what I need removed from the file names. I ran your BAT and with

@echo off outputs this to screen:
"IMG_2011_05_SYSTEM_FIVE_00001.jpg" "IMG_2011_05_00001.jpg"

When I remove @echo off I get this to screen:
set OldName=IMG_2011_05_SYSTEM_FIVE_00001
 set NewName=!OldName:_SYSTEM_FIVE=!
 ECHO ren "c:\test\2011_05_SYSTEM_FIVE_00001.jpg" "!NewName!.jpg"
)
ren "c:\test\2011_05_SYSTEM_FIVE_00001.jpg" "2011_05_00001.jpg"

But, the actual files in c:\test are not changed?

Did I miss something?

Thanks!


0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
Bill PrewCommented:
Yes, you don't want to change the first @ECHO OFF line, but rather the line"

  ECHO ren "%%~A" "!NewName!.jpg"

~bp
0
 
funkyjoe1Author Commented:
Worked perfectly! Thanks!
0
 
Bill PrewCommented:
Great, welcome.

~bp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.