Rename Files in Dir

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
sstegnerr
Posts: 1
Joined: 08 Nov 2018 21:44

Rename Files in Dir

#1 Post by sstegnerr » 08 Nov 2018 21:55

Have following script for deleting the word "KILLERS" from file names in current Dir. I [want] to CHANGE name "KILLERS" to ZIGGY. how do I rewrite this script please? Thank you

Code: Select all

@echo off & setlocal

for /r /d %%a in (*) do call:strip "%%a"
for /r %%a in (*) do call:strip "%%a"
goto:eof

:strip
set app=%~n1&set ver=
set app=%app:v0=&set ver=v0%
set app=%app:v1=&set ver=v1%
set app=%app:v2=&set ver=v2%
set app=%app:v3=&set ver=v3%
set app=%app:v4=&set ver=v4%
set app=%app:v5=&set ver=v5%
set app=%app:v6=&set ver=v6%
set app=%app:v7=&set ver=v7%
set app=%app:v8=&set ver=v8%
set app=%app:v9=&set ver=v9%
set app=%app:.= %

set app=%app:KILLERS=%

if /i "%~nx1" neq "%app%%ver%%~x1" (
	set pad=%app%                           
	echo Renaming App : %pad:~,25% Ver :	%ver%	Ext : %~x1
	ren "%~1" "%app%%ver%%~x1"
)

Squashman
Expert
Posts: 4012
Joined: 23 Dec 2011 13:59

Re: Rename Files in Dir

#2 Post by Squashman » 09 Nov 2018 10:13

Code: Select all

set app=%app:KILLERS=%
So what do you think you have to change in this line of code?

Post Reply