这个是我目前解决办法,字符-为锚点取左边的文字,语文1 这样文件夹就会是语文
但是只能个位数。。。。主要是想以出现的第一个数字,取左侧文本作为文件夹并移入- @echo off
- cd /d "%~dp0"
-
- setlocal enabledelayedexpansion
-
- for /f "delims=" %%D in ('dir /ad /b /s') do (
- pushd "%%D"
- for /f "delims=" %%i in ('dir /b /a-d "*-*"') do (
- set "filename=%%i"
- set "folderName="
- for /f "tokens=1* delims=-" %%a in ("!filename!") do (
- set "folderName=%%a"
- set "folderName=!folderName:~0,-1!" // 新增这一行,去除数字部分
- if not exist "!folderName!" (
- md "!folderName!"
- )
- move "%%i" "!folderName!"
- )
- )
- popd
- )
-
- endlocal
- pause
复制代码
|