I need to add in a conditional statement to check for a folder so that it can exexute the below script. Lets say the script is placed in folder c:/temp/A but I want the script to excute and change the file extensions of files in a another directory d:/xxx/B. If directory B doesnt exists, throw an error and exit. I tried using if else statement but its says no else statement is allowed. Please help me out and let me know how it can be done.
@echo off
setlocal ENABLEDELAYEDEXPANSION
for %%F in (*.*_error* *.*error_*) do ( set "ext=%%~xF"
SET "ext=!ext:_error=!"
ren "%%F" "%%~nF!ext:error_=!"
)