Code: Select all
@echo off
echo D:\somefiles\peter&mary.txt
echo "D:\somefiles\peter&mary.txt"
echo "D:\somefiles\peter+(mary).txt"
pause
Moderator: DosItHelp
Code: Select all
@echo off
echo D:\somefiles\peter&mary.txt
echo "D:\somefiles\peter&mary.txt"
echo "D:\somefiles\peter+(mary).txt"
pause
pstein wrote:If there is really a problem: Can I somehow tell DOS to automatically mask at first such critical chars to
will not be quoted, when calling the batch file.D:\somefiles\peter&mary.txt
Peter&Mary,Miller.txt
John, Smith.txt
Code: Select all
myDragDrop.bat C:\Peter&Mary,Miller.txt "John, Smith.txt"
C:\Peter&Mary,Miller.txt
"John, Smith.txt"
pstein wrote:I prefer not to use your tricky SHIFT and GOTO solution but keep it in short, more human readable ol' style.
Code: Select all
@echo off &setlocal DisableDelayedExpansion
setlocal EnableDelayedExpansion
set "params=!cmdcmdline:~,-1!"
set "params=!params:*" =!"
if "!params!"=="" (endlocal &goto end)
endlocal&set "params=%params:"=""%"
set "params=%params:^=^^%"
set "params=%params:&=^&%"
set "params=%params: =^ ^ %"
set params=%params:""="%
set "params=%params:"=""Q%"
set "params=%params: ="S"S%"
set "params=%params:^ ^ = %"
set "params=%params:""="%"
setlocal EnableDelayedExpansion
set "params=!params:"Q=!"
for %%i in ("!params:"S"S=" "!") do (
if "!!"=="" endlocal
if not exist "%%~i\" (
set "file=%%~i"
call :proc
)
)
:end
echo finished
pause
exit
:proc
echo process "%file%" here
goto :eof
pstein wrote:Sorry I still have problems to find the problem.
Assume I have this three files:
peter&(mary).txt
(peter)&,mary,.txt
(peter&;,mary).txt
Now I drag them (under 64bit Win7) onto a batch script with the following code (I found meanwhile):
....then everything is fine. No crash. No half detected parms. All three were double quoted.
Let me know a DOS batch code which will crash when I drag the three files mentioned above.
pstein wrote:So not filenames but file pathes matters.
One more idea to avoid this last, working, but long-winded handling code from aGerman:
Maybe there is a 3rd party helper tool which prepares the passed parameters
aGerman wrote:Code: Select all
@echo off &setlocal DisableDelayedExpansion
setlocal EnableDelayedExpansion