Search code examples
windowsbatch-filecopycmdquotes

CMD: Check for quotes


Let's say, the user drag and drops an file into my batch file, which causes that the batch file copies the file to a certain directory. the problem is the following command:

copy "%1" "C:\path\to\it"

The problem here is the quotes around%1. When you drag and drop something in a batch file, normally, it wouldn't put quotes, so everything's fine. But when i convert my batch file to EXE, it actually puts quotes there.

So, what i want to do is, checking if the file does have quotes, if not, than do the command above, otherwise, do the command without quotes.

Thanks.


Solution

  • Would the following work?

    copy %1 "C:\Dir1\Dir2"
    

    my few attempts to find a problem not quoting %1 have not resulted in adverse effects.