I have a diff script that wraps the command FC
so that I just have to drop two files on it:
FC /L /N "%1" "%2" > diff.out.txt 2> diff.err.txt
It works fine, but if one of the files has spaces in the name...
For example, my file paths being C:\Users\joH1\Desktop\file_with a_space.txt
and C:\Users\joH1\Desktop\file_2.txt
, I get the error (sorry for localization):
FC : commutateur non valide
FC : impossible d'ouvrir C:\USERS\JOH1\DESKTOP\FILE_WITH - Ce fichier ou dossier n'existe pas
So, the file name is split as two separate arguments, even though the paths are quoted.
To find out where this comes from, I added lines to my script:
echo %1
echo %2
FC /L /N "%1" "%2" > diff.out.txt 2> diff.err.txt
pause
I get correct output for the echo
s (though args are unquoted!):
"C:\Users\joH1\Desktop\file_with a_space.txt"
"C:\Users\joH1\Desktop\file_2.txt"
I even tried with dir
to make sure echo
was not merging back the split args, and I got a correct result (file was recognized and listed => name not split).
So; I guess FC
is to blame here.
Is there a way of telling it not to split a file name? (like quotes are supposed to?)
I'd like a way that is compatible with drag & drop, and that is not Rename your files without spaces, if possible...
Thanks in advance!
FC /L /N "%~1" "%~2" > diff.out.txt 2> diff.err.txt
should read your files. I'm assuming your parameters are merely double-quoted and that they don't contain ` as posted.