1、2、
[ 本帖最后由 tireless 于 2008-12-18 08:05 编辑 ]
tireless 发表于 2008-12-17 22:53
我试了下上边的所有脚本会导致文件名-左右删字符
如:AAA-BBB 会生成 BB-AA
然而我们需要的是生成BBB-AAA
以下提供可用脚本- @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"
- )
复制代码
|