本帖最后由 ArdentMan 于 2011-7-8 20:23 编辑
出错是因为Str变量的值没有得到传递,想了很多办法也不行,只好用个临时文件tem了- @Echo Off&SetLocal EnableDelayedExpansion
- For /R %%a In (*.mp4 *.rmvb) Do (
- Set "Str=%%~nxa"&Set "Flag="
- For /F "Delims=" %%b In ('Dir /ad /b /s F:\视频') Do (
- If Not Defined Flag (
- Set "Var=%%~nb"
- For %%c In ("!Var!") Do If "!Str:%%~c=!" NEQ "!Str!" If "!Var:~4!" NEQ "" Set "Flag=a"
- For %%c In ("!Str!") Do If "!Var:%%~c=!" NEQ "!Var!" If "!Str:~4!" NEQ "" Set "Flag=a"
- If Defined Flag Move "%%a" "%%b\"
- )
- )
- If Not Defined Flag (
- SetLocal&Cls
- Echo 视频文件:%%~nxa&Echo,
- For /f "Delims=" %%b In ('Dir /ad /b F:\视频') Do (
- Set /A Num+=1,Number+=1&Set ".!Num!=F:\视频\%%b"
- Set "Str=000!Num!"&Set "Var=%%b "
- Set /P=[!Str:~-3!]!Var:~,20!<nul
- If "!Number!" EQU "2" Echo,&Set /A Number=0
- )
- Echo,&Set "Str="&Set /P Str=请选择文件夹:
- For %%b in (!Str!) do Echo !.%%b!>tem
- EndLocal
- Set /p Str=<tem&Del tem
- Echo,&Set "Var="&Set /P Var=请输入模式(A或者D):
- If /i "!Var!" EQU "D" (
- SetLocal&Cls
- Echo 视频文件:%%~nxa&Echo,
- For /F "Delims=" %%b In ('Dir /s /ad /b "!Str!"') Do (
- Set /A Num+=1,Number+=1&Set ".!Num!=%%b"
- Set "Str1=000!Num!"&Set "Var=%%b "
- Set /P=[!Str1:~-3!]!Var:~,20!<nul
- If "!Number!" EQU "2" Echo,&Set /A Number=0
- )
- Echo,&Set "Str="&Set /P Str=请选择文件夹:
- For %%b in (!Str!) do Echo !.%%b!>tem
- EndLocal
- Set /p Str=<tem&Del tem
- )
- Cls&Set /P Name=所选文件夹是!Str!,请输入新文件夹名:
- If Not Exist "!Str!\!Name!" Md "!Str!\!Name!"
- Move "%%a" "!Str!\!Name!\"
- )
- )
复制代码
|