So i have this code to output the filesize of a file, then replace the file and check the size again:
FOR %%A IN (%userprofile%\remove.me) DO (
set size=%%~zA
)
pause
echo before:%size%
copy %userprofile%\copy.me %userprofile%\remove.me
pause
FOR %%B IN (%userprofile%\remove.me) DO (
set size2=%%~zB
)
pause
echo after:%size2%
pause
exit
It works perfectly fine, but when i try to check if the remove.me file exists before executing the code it wont output the filesizes:
if EXIST %userprofile%\remove.me (
FOR %%A IN (%userprofile%\remove.me) DO (
set size=%%~zA
)
pause
echo before:%size%
copy %userprofile%\copy.me %userprofile%\remove.me
pause
FOR %%B IN (%userprofile%\remove.me) DO (
set size2=%%~zB
)
pause
echo after:%size2%
pause
exit
)
It will just say
before:
after:
without the filesizes. If i try to escape the brackets inside the code that gets run by the if-statement it will just return that (C:\Users\Myaccountname\remove.me) does not follow the syntax.
I can't figure out why this is happening and how to fix this. Don't judge me, im new to batch .-.
if EXIST "%userprofile%\remove.me"andFOR %%A IN ("%userprofile%\remove.me")