how do i pass a variable that has @ in it?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
nnnmmm
Posts: 141
Joined: 26 Aug 2017 06:11

how do i pass a variable that has @ in it?

#1 Post by nnnmmm » 30 Dec 2022 09:54

Code: Select all

SET Y1=@OK games
SET M1=%~d0%\%Y1%\AVP 2 - v1091\!AVP 2 - V1091.BAT
SET M2=%~d0%\%%Y1%%\AVP 2 - v1091\!AVP 2 - V1091.BAT
SET M3=%~d0%\\%%Y1%%\AVP 2 - v1091\!AVP 2 - V1091.BAT
SET M4=%~d0%\\\%%Y1%%\AVP 2 - v1091\!AVP 2 - V1091.BAT
SET M5=%~d0%%Y1%%\AVP 2 - v1091\!AVP 2 - V1091.BAT

SET T1=%~d0%\@OK games\AVP 2 - v1091\!AVP 2 - V1091.BAT

ECHO "%M1%"
ECHO "%M2%"
ECHO "%M3%"
ECHO "%M4%"
ECHO "%M5%"

ECHO "%T1%"

PAUSE
GOTO :EOF
M1 M2 M3 M4 M5 dont work
only doing it like T1 works
how do i pass a variable that has @ in it?
the reason why i use ! and @ for a dir or a file name is they are the 1st ones to show in the line

Lucky4Me
Posts: 24
Joined: 21 Oct 2020 06:33

Re: how do i pass a variable that has @ in it?

#2 Post by Lucky4Me » 30 Dec 2022 11:09

Remove the % at the end of %~d0%
like this

SET M1=%~d0\%Y1%\AVP 2 - v1091\!AVP 2 - V1091.BAT
SET M2=%~d0\%Y1%\AVP 2 - v1091\!AVP 2 - V1091.BAT
SET M3=%~d0\%Y1%\AVP 2 - v1091\!AVP 2 - V1091.BAT
SET M4=%~d0\%Y1%\AVP 2 - v1091\!AVP 2 - V1091.BAT
SET M5=%~d0\%Y1%\AVP 2 - v1091\!AVP 2 - V1091.BAT

nnnmmm
Posts: 141
Joined: 26 Aug 2017 06:11

Re: how do i pass a variable that has @ in it?

#3 Post by nnnmmm » 31 Dec 2022 23:20

thanks for the help

a half of my batch files uses %~d0% and the other half %~d0, then time went by decades.
i will try to replace %~d0% with %~d0 if i can, from 100's batches for 1000's implications.

Post Reply