let's say I have a file with a space in the filename:
Code: Select all
@echo off
>file1.txt (echo TEST)
>"file 2.txt" (echo TEST)
if exist "file1.txt" echo 1
if exist ""file1.txt"" echo 2
if exist "file 2.txt" echo 3
if exist ""file 2.txt"" echo 4
results:
Code: Select all
1
2
3
So file "file 2.txt", which has space in the filename, is not recognized and this might cause problems. If filename does not contain a space double quotes are OK.
So it is important to remove duplicate quotes for the program to work as expected.
And now make files 'file' and '2.txt' (file 'file has no extension).
Run the command procedure again. Notepad (or your default .txt editor) will open.
Remove the 'file' file and run it again. Notepad is not started.
Again create the 'file' file and remove file 2.txt.
Now the error we get is:
Code: Select all
2.txt"" is not recognized as an internal command...
Maybe this helps someone.
Saso