Delayed Expansion will cause variables to be expanded at execution time rather than at parse time, this option is turned on with the
SETLOCAL
command. When delayed expansion is in effect variables can be referenced using!variable_name!
(in addition to the normal%variable_name%
)
Portanto, use !A!
, !A:~0,1!
e !A:~1!
em vez de %A%
, %A:~0,1%
e %A:~1%
, respectivamente, da seguinte forma:
SETLOCAL ENABLEEXTENSIONS
SET A=%%~nxF
IF "!A:~0,1!"=="@" (
ECHO. RENAME "!A!" "!A:~1!"
RENAME "!A!" "!A:~1!"
) ELSE (
ECHO. File does not start with @: !A!
)
ENDLOCAL