本帖最后由 zhengzhenhui 于 2024-8-17 20:04 编辑
遍历当前文件夹下的所有目录的多个关键字移入指定名称的文件夹,没有则创建- @echo off
- setlocal EnableDelayedExpansion
- cd /d "%~dp0"
- rem 定义要匹配的关键字和目标文件夹
- set "keywords=周杰伦 林俊杰 张惠妹 刘德华"
- set "targetFolder=爱听的文件夹"
- if not exist "%targetFolder%" (
- mkdir "%targetFolder%"
- )
- for /r %%a in (*.*) do (
- set "fileName=%%~nxa"
- for %%k in (%keywords%) do (
- if /i "!fileName!" neq "!fileName:*%%k=!" (
- echo Moving "%%a" to "%targetFolder%"
- move "%%a" "%targetFolder%" >nul 2>&1 || echo Error moving file: "%%a"
- )
- )
- )
-
- endlocal
复制代码
|