Avatar of dmanisit
dmanisit

asked on 

Script to rename many files

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?
Microsoft DOSVB Script

Avatar of undefined
Last Comment
dmanisit
Avatar of knightEknight
knightEknight
Flag of United States of America image

@echo off
setlocal enabledelayedexpansion

CD/d "C:\myfolder"

for %%F in (Q-Images*.TIF) do (
  set _FN=%%F
  ren  "!_FN!"  "!_FN:~8!"
)
Avatar of knightEknight
knightEknight
Flag of United States of America image

alternatively, you can replace this line:

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

with this one:

   echo ren "!_FN!"  "!_FN:Q-Images=!"
Avatar of knightEknight
knightEknight
Flag of United States of America image

oops, but remove the "echo" from the second one.
ASKER CERTIFIED SOLUTION
Avatar of knightEknight
knightEknight
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
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

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.
Avatar of dmanisit
dmanisit

ASKER

thank you
VB Script
VB Script

VBScript (Visual Basic Scripting Edition) is an interpreted scripting language developed by Microsoft that is modeled on Visual Basic, but with some important differences. VBScript is commonly used for automating administrative and other tasks in Windows operating systems (by means of the Windows Script Host) and for server-side scripting in ASP web applications. It is also used for client-side scripting in Internet Explorer, specifically in intranet web applications.

39K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo