I've written a video convertion batch, where the user can simply drag and drop his videos from any disk or partition onto the batch, after which the converted video will be saved on a particular location on a particular disk.
The code looks like this
@echo off
%~d0
cd %~p0
for %%f in (%*) do ...
pause
The actual problem lies with (%*)
.
When my file has a closing round bracket in its name, the batch won't work. To fix this, I used ("%*")
, but this doesn't work with files that have spaces in their names, or with multiple files.
I also tried with (%~*)
but that is invalid.
After some research I noticed, that when I drop multiple files on the batch with the names file(test)
and file test
, %*
resolves to
file(test) "file test"
Which means that a filename may have quotation marks, or not...
My question is: How do I deal with this?
Ideally, I would like %*
to resolve to "file(test)" "file test"
(both names wrapped around quotes)