Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Ed Dyreen
- Expert
- Posts: 1569
- Joined: 16 May 2011 08:21
- Location: Flanders(Belgium)
-
Contact:
#1
Post
by Ed Dyreen » 03 Nov 2012 19:43
'
When working on
this file I noticed I couldn't handle a drag'n drop fileName with a caret.
I know batch can't handle many special chars, but a caret

drag'n drop 'no^Caret.TST' -> 'can'tDo.CMD'
Code: Select all
echo.%*
echo."%~*"
echo.%1
echo."%~1"
pause
-
jeb
- Expert
- Posts: 1062
- Joined: 30 Aug 2007 08:05
- Location: Germany, Bochum
#2
Post
by jeb » 04 Nov 2012 01:19
Hi ED,
as Drag&Drop is a bit strange implmented with batch, it's not safe to use %1, %2...
As you can see the carets are a bit problematic, but this&taht.txt will kill your batch file completly.
The best way I know, is to use !cmdcmdline! to access the drag&drop files and exit the batch explicitly with EXIT
Drag and drop batch file for multiple files?jeb
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#3
Post
by foxidrive » 04 Nov 2012 04:21
Ed Dyreen wrote:'
When working on
this file I noticed I couldn't handle a drag'n drop fileName with a caret.
I know batch can't handle many special chars, but a caret

drag'n drop 'no^Caret.TST' -> 'can'tDo.CMD'
Code: Select all
echo.%*
echo."%~*"
echo.%1
echo."%~1"
pause
FWIW this syntax error kills the batch file completely in Win8.
The following usage of the path operator in batch-parameter
substitution is invalid: %~*"^ is as bad as % in batch files.
-
Ed Dyreen
- Expert
- Posts: 1569
- Joined: 16 May 2011 08:21
- Location: Flanders(Belgium)
-
Contact:
#4
Post
by Ed Dyreen » 04 Nov 2012 17:35
'
That should work

( I will test it shortly )
Jeb, thanks once more !