hi,
I have below script that add a prefix to all files available in a folder.
how to include another if statement that if a file name already contains A23_ as prefix in the folder it should skip it?? pls help. thxs
@echo off
set "dir=C:\TEST"
set "pfx=A23_"
setlocal enabledelayedexpansion
for /r "%dir%" %%A in (*.txt) do (
set "txt=%%~nA"
if not "!txt:~0,13!"=="%pfx%" ren "%%A" "%pfx%%%~nxA"
)
pause
batch script to skip file is file name contains a specific prefix
Moderator: DosItHelp
Re: batch script to skip file is file name contains a specific prefix
Your code is comparing 13 characters of the file name to 4 characters of your prefix string. That will never be true.