1
我想對圖像中的某些東西在擴展名中定義變量。 下面的腳本運行良好:Windows批處理腳本 - 如何使用定義的擴展名篩選文件
set AllowExt="jpg png bmp"
forfiles /p D:\Pictures /m *.* /c "cmd /c if not %AllowExt:jpg=% == %AllowExt% echo @file
但下面的腳本拋出錯誤
set AllowExt="jpg png bmp"
forfiles /p D:\Pictures /m *.* /c "cmd /c if not %AllowExt:@ext=% == %AllowExt% echo @file"
ERROR:無效的參數/選項 - 'PNG'。 輸入「FORFILES /?」供使用。
修正如下,它運行良好。 組AllowExt = .JPG .PNG .BMP 用於%%一個在(%AllowExt%)做( FORFILES/P d:\圖片/米* %%的A/C 「CMD/C回波@file」 ) –
@JinHo你說得對,應該沒有雙引號:) – Endoro