本帖最后由 Linuxer 于 2014-10-10 10:49 编辑
回复 8# 李安阳
单独还原:- @echo off
- setlocal enabledelayedexpansion
- ::设置目标路径
- set "FileDir=C:\Test"
- for /f "delims=" %%i in ('dir /ad /b %FileDir%') do (
- set a_name=%%i
- ren "%FileDir%\%%i" "!a_name:~0,-2!"
- )
- pause
复制代码 带改名和还原。输入1就是改名,输入2就是还原。目标路径自己修改下。- @echo off
- setlocal enabledelayedexpansion
- ::设置目标路径
- set "FileDir=C:\Test"
-
- :dowhat
- set /p input=请输入数字(改名:1,还原:2):
- if not defined input echo 未输入内容&goto dowhat
- if "%input%" equ "1" (
- goto renamed
- ) else if "%input%" equ "2" (
- goto restore
- ) else (
- echo 输入错误
- goto dowhat
- )
- ::改名
- :renamed
- for /f "delims=" %%i in ('dir /ad /b %FileDir%') do (
- ren "%FileDir%\%%i" "%%i路过"
- )
- goto :eof
-
- ::还原
- :restore
- for /f "delims=" %%i in ('dir /ad /b %FileDir%') do (
- set a_name=%%i
- ren "%FileDir%\%%i" "!a_name:~0,-2!"
- )
- goto :eof
复制代码
|