為什麼這個腳本可以在命令列中運行,但當我將其放入 Windows 批次檔中時卻不能運行?

為什麼這個腳本可以在命令列中運行,但當我將其放入 Windows 批次檔中時卻不能運行?

這是我可以從命令列運行的腳本:

(for /r %i in (*) do @echo %~fsi) | clip

但在批次檔中,我收到有關意外括號的語法錯誤...

) was unexpected at this time.

(for /r ~fsi) | clip

答案1

大量嘗試:

@Echo Off
(for /r %%i in (*) do echo %%~fsi) | clip

在批次檔中運行時必須加倍 % 符號。

相關內容