下面这个代码是根据文件名的后面4位字符来批量建立文件夹的,我现在想把他改成根据文件名前面7位字符来建立文件夹
请问应该怎么改法?- @echo off
- rem 截取/提取文件名末尾的几位字符作为名称来创建文件夹,并把文件剪切/移动到该新建的文件夹里
- set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
- title %#% +%$%%$%/%@% %z%
- cd /d "%~dp0"
- rem 后4位字符
- set "n=4"
- for /f "delims=" %%a in ('dir /a-d/b') do (
- if /i "%%~nxa" neq "%~nx0" (
- set "fname=%%~na"
- set "f=%%a"
- setlocal enabledelayedexpansion
- if not exist "!fname:~-4!\" md "!fname:~-4!\"
- echo;"!f!" --^> "!fname:~-4!\"
- endlocal
- )
- )
- echo;%#% +%$%%$%/%@% %z%
- pause
- exit
复制代码
|