Home > OS >  Batch batch, to determine whether a file exists, the file path with variable doesn't work
Batch batch, to determine whether a file exists, the file path with variable doesn't work

Time:10-16

The batch code is as follows,
The set file_nameSplit=C: \ Users \ wu_xi \ Desktop \ work \ bat \ TMP \ pit_result_201607210001 zip

If not exist % % file_nameSplit goto nofiles
Echo exist
Pause
The exit
: nofiles
Echo not exist
Pause

The file exists, I directly write
If not exist C: \ Users \ wu_xi \ Desktop \ work \ bat \ TMP \ pit_result_201607210001 zip goto nofiles
Will correct the execution of the echo exist
But I change variables, you always judge file does not exist: nofiles
Echo not exist

Everybody to help me see where I write wrong?

CodePudding user response:

To solve the problem,
The set file_nameSplit=C: \ Users \ wu_xi \ Desktop \ work \ bat \ TMP \ pit_result_201607210001 zip
Behind the variables and the value of the equal sign between, need not add Spaces,
Set file_nameSplit=C: \ Users \ wu_xi \ Desktop \ work \ bat \ TMP \ pit_result_201607210001 zip is right,

CodePudding user response:

Help knot stick + points
  • Related