Ignore percent sign in batch file

后端 未结 6 2382
北恋
北恋 2020-11-22 14:33

I have a batch file which moves files from one folder to another. The batch file is generated by another process.

Some of the files I need to move have the string \"

6条回答
  •  孤独总比滥情好
    2020-11-22 15:03

    You need to use %% in this case. Normally using a ^ (caret) would work, but for % signs you need to double up.

    In the case of %%1 or %%i or echo.%%~dp1, because % indicates input either from a command or from a variable (when surrounded with %; %variable%)

    To achieve what you need:

    move /y "\\myserver\myfolder\file%%20name.txt" "\\myserver\otherfolder"
    

    I hope this helps!

提交回复
热议问题