1 使⽤for,截取_之后的⽂件名,并重命名怎么共享打印机
海贼王cp9@echo off & setlocal enableDelayedExpansion
set /p path=please paste/input your Excel Path :
cd /d %path%
rem 2这是通过循环去修改⽂件夹⾥⾯的⽂件
for /f "tokens=1-3 delims=_" %%i in ('dir /aa /b %path%') do (
::echo in progressing %%i_%%j_%%k
段林希图片介词with的用法ren "%%i_%%j_%%k" %%k
)
rem 3结束,并打开⽂件位置
echo.
echo.
echo its ok now,the file locate at %path%
C:\ %path%
把这个放到bat⽂件⾥⾯,运⾏,按提⽰输⼊,就没问题了
2 替换⽂件名中的_,可以替换成任何字符,我这⾥只置空
@echo off & setlocal enableDelayedExpansion
rem 1这是提⽰输⼊⽂件位置,直接打开⽂件夹复制路径、黏贴就⾏
set /p path=please paste/input your Excel Path :
刘洲成微博cd /d %path%
rem 2这是通过循环去修改⽂件夹⾥⾯的⽂件名字
袁惟仁是谁for /f "delims=!" %%i in ('dir /aa /b %path%') do (
::echo in progressing %%i_%%j_%%k
set str1=%%i
set str2=!str1:_=!
echo str1 is !str1! str2 is !str2!
ren "!str1!""!str2!"
)
rem 3结束,并打开⽂件位置
echo.
echo.
echo its ok now,the file locate at %path%
C:\ %path%
⼆者⽅法都类似,⽤到了for,⽤到了变量,和延迟变量开关
reference
发布评论