我正在尝试循环遍历一组文件扩展名,我能够将其定位到第一个扩展名但更改了代码,现在我无法记住我所做的事情。无论我使用的代码是什么,都不会遍历扩展数组。如果您可以参考帮助答案的链接进行解释。
:: ACTION :: 1 CLEAN
:cleanup
set "Fdocs=%CD%\1_docs"
set "Fphotos=%CD%\2_photos"
set "Fdesigns=%CD%\3_designs"
set "Freviews=%CD%\4_reviews"
set "Ffinal=%CD%\5_final"
set "$ext="
set "action=Cleaning"
:: CLEAN :: documents
set "$ext=.txt .doc .docx .xls .csv .ppt .pptx"
call :fMover "%$ext%" "%Fdocs%"
cls
echo %action% project folder.
:: CLEAN :: images
set "$ext=.jpg .png .tiff .raw .nef .crw .dng"
call :fMover "%$ext%" "%Fphotos%"
cls
echo %action% project folder..
:: CLEAN :: designs
set "$ext=.psd .psb"
call :fMover "%$ext%" "%Fdesigns%"
set "$ext=.ai .svg .svgz .esp"
call :fMover "%$ext%" "%Fdesigns%"
set "$ext=.indd .idml"
call :fMover "%$ext%" "%Fdesigns%"
cls
echo %action% project folder...
echo done.
goto :intro
:fMover
for /F "usebackq tokens=* delims==" %%G in ('dir /b /s %CD%\*%~1') do (
rem move %%G %~2
echo "%%G" %~2
echo %~2
rem echo %~1
timeout 2 >nul
pause
goto :eof
)
答案 0 :(得分:0)
你的问题:fMover子程序:
将您的:FMover更改为此,然后根据需要进行更改。
:fMover
pause
for /F "tokens=1*" %%G in ('echo.%~1') do (
echo.
echo.Move files with extension=%%G to %~2
for /F "usebackq tokens=*" %%K in (`dir /b /s "%CD%\*%%G"`) do (
echo %%K
rem move %%K %~2
)
if not "%%H"=="" call :fMover "%%H" "%~2"
)
goto :eof
作为解释:
一些一般性建议:
让一些工作变得非常令人沮丧,然后通过做出太多改变而失去它:)