我正在尝试将名称中包含部分数据的文件移动到文件名中该字符串的新文件夹中!
myfiles[sql-data-2232]sql.dat [want to move it and create folder sql-data-2232]
myfiles[jpg-data-2232]jpg.img [want to move it and create folder jpg-data-2232]
myfiles[whatever-number]xyz.xyz [want to move it and create folder whatever-number]
文件名中的括号包含要移动到的文件的文件夹名称!
答案 0 :(得分:3)
在示例文件的文件夹上测试。
@echo off
for /f "delims=" %%a in ('dir "myfiles*" /b /a-d ') do (
for /f "tokens=2 delims=[]" %%b in ("%%a") do MD "%%b" 2>nul & move "%%a" "%%b" >nul
)
echo done
pause