这里16楼是正确答案
http://www.bathome.net/viewthrea ... mp;extra=#pid222966- @echo off&setlocal EnableDelayedExpansion
- for /f "tokens=1,2 delims=-." %%a in ('dir /b *.mp3') do (
- set var=%%a
- ::去除var变量左边第一个空格
- if "!var:~0,1!"==" " set var=!var:~1!
- if "!var:~0,1!"==" " set var=!var:~1!
- if "!var:~0,1!"==" " set var=!var:~1!
- if "!var:~0,1!"==" " set var=!var:~1!
- if "!var:~0,1!"==" " set var=!var:~1!
- if "!var:~0,1!"==" " set var=!var:~1!
- if "!var:~0,1!"==" " set var=!var:~1!
- if "!var:~0,1!"==" " set var=!var:~1!
- ::去除var变量右边第一个空格
- if "!var:~-1!"==" " set var=!var:~0,-1!
- if "!var:~-1!"==" " set var=!var:~0,-1!
- if "!var:~-1!"==" " set var=!var:~0,-1!
- if "!var:~-1!"==" " set var=!var:~0,-1!
- if "!var:~-1!"==" " set var=!var:~0,-1!
- if "!var:~-1!"==" " set var=!var:~0,-1!
- if "!var:~-1!"==" " set var=!var:~0,-1!
- if "!var:~-1!"==" " set var=!var:~0,-1!
- set jar=%%b
- ::去除jar变量左边第一个空格
- if "!jar:~0,1!"==" " set jar=!jar:~1!
- if "!jar:~0,1!"==" " set jar=!jar:~1!
- if "!jar:~0,1!"==" " set jar=!jar:~1!
- if "!jar:~0,1!"==" " set jar=!jar:~1!
- if "!jar:~0,1!"==" " set jar=!jar:~1!
- if "!jar:~0,1!"==" " set jar=!jar:~1!
- if "!jar:~0,1!"==" " set jar=!jar:~1!
- if "!jar:~0,1!"==" " set jar=!jar:~1!
- ::去除jar变量右边第一个空格
- if "!jar:~-1!"==" " set jar=!jar:~0,-1!
- if "!jar:~-1!"==" " set jar=!jar:~0,-1!
- if "!jar:~-1!"==" " set jar=!jar:~0,-1!
- if "!jar:~-1!"==" " set jar=!jar:~0,-1!
- if "!jar:~-1!"==" " set jar=!jar:~0,-1!
- if "!jar:~-1!"==" " set jar=!jar:~0,-1!
- if "!jar:~-1!"==" " set jar=!jar:~0,-1!
- if "!jar:~-1!"==" " set jar=!jar:~0,-1!
- ::重命名文件
- ren "%%a-%%b.mp3" "!jar!-!var!.mp3"
- )
复制代码
|