Script to rename many files

dmanisit
dmanisit used Ask the Experts™
on
Hi, I have about 2000 image files that are structured like this: Q-Images0D264A61-9F97-4E6A-8EC8-500156287BEC0001.TIF I need a script that will drop the Q-images and leave everything else. Can anyone help?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
@echo off
setlocal enabledelayedexpansion

CD/d "C:\myfolder"

for %%F in (Q-Images*.TIF) do (
  set _FN=%%F
  ren  "!_FN!"  "!_FN:~8!"
)
alternatively, you can replace this line:

   ren  "!_FN!"  "!_FN:~8!"

with this one:

   echo ren "!_FN!"  "!_FN:Q-Images=!"
oops, but remove the "echo" from the second one.
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Anyway, save the above script to a .BAT file, and change the path and folder to match the place where you store your .TIF files.
Justin EllenbeckerIT Director

Commented:
Are the filenames a static length? if they are this should do it.
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFS.GetFolder("C:\PATH")
For Each oFile In oFolder.Files
	WScript.Echo oFile.name
	WScript.Echo oFile.path
	If Left(Lcase(oFile.name),8) = "q-images" Then
		oFS.CopyFile oFile.path, "C:\PATH\" & Right(oFile.name,Len(oFile.name) - 7)
	End If
Next

Open in new window

Justin EllenbeckerIT Director

Commented:
actually that will work if they are not static it is going to look at the length of the file name and take 7 off of that which should remove the Q-Images portion of every file.

Author

Commented:
thank you

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial