批处理batch,判断文件是否存在,文件路径换成变量就不起作用了
批处理代码如下。
set file_nameSplit = C:\Users\wu_xi\Desktop\work\bat\tmp\pit_result_201607210001.zip
if not exist %file_nameSplit% goto nofile
echo exist
pause
exit
:nofile
echo not exist
pause
这个文件是存在的,我直接写
if not exist C:\Users\wu_xi\Desktop\work\bat\tmp\pit_result_201607210001.zip goto nofile
就会正确的执行echo exist
但是我换成变量的话,就总是判断文件不存在:nofile
echo not exist
大家帮我看看我哪儿写错了?