views:

30

answers:

3

The code that is confusing me:

set CLEAN=\Users\%USERNAME%\Documents\Directory One\Sub Directory\30% Dalton.txt
IF EXIST %CLEAN% echo "It Works"

This code will never work because the file name has a " % " char

Is there a way to get around this and produce the Echo "It Works"

+2  A: 
set CLEAN=\Users\%USERNAME%\Documents\Directory One\Sub Directory\30%% Dalton.txt
IF EXIST "%CLEAN%" echo "It Works"
BillP3rd
You need to put quotes around `%CLEAN%` because your file/path contains spaces.
BillP3rd
+1  A: 

Use a double % sign. A quick Google led me to the answer.

http://www.robvanderwoude.com/escapechars.php

set CLEAN=\Users\%USERNAME%\Documents\Directory One\Sub Directory\30%% Dalton.txt
IF EXIST %CLEAN% echo "It Works"
Marc W
A: 

Do

%%

to escape

Woot4Moo