批处理 ren(批处理rename)

批处理 ren(批处理rename)echo off amp setlocal enabledelaye title Import and Rename color 0a mode con lines 35 cols 75 comment set a 0 set b 0 set c 0 cls color 0a rem

大家好,我是讯享网,很高兴认识大家。



@echo off&setlocal enabledelayedexpansion title Import-and-Rename color 0a @mode con lines=35 cols=75 :comment set a=0 set b=0 set c=0 cls color 0a rem +++++++++++++++++++++++++++++++++++++++++++ rem OneKeyImportRename.bat rem By zhzw @2017/5/22 rem  rem Version: 1.4 rem +++++++++++++++++++++++++++++++++++++++++++ echo. echo 注意事项!!! echo. echo 1.截图必须为criterion.txt对应的顺序 echo. echo 2.打开USB,连接设备,勾选总是允许USB调试.输入code(如:US)即可. echo. echo 3.若运行中出现异常请根据提示操作(不要操作criterion.txt,name.txt文件). echo. echo ==================================== end ================================

讯享网

rem ====================================================================== :input color 0a set /p code=InputCountryCode: :search findstr ”/c:-%code%” name.txt >nul if not %errorlevel%== 0 (

讯享网color 0d </span><span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(0, 0, 255, 1)">Not</span> <span style="color: rgba(0, 0, 255, 1)">exist</span>.<span style="color: rgba(0, 0, 0, 1)"> Please reenter ping </span>127.0.0.1 -n 3 &gt;<span style="color: rgba(0, 0, 0, 1)">nul </span><span style="color: rgba(0, 0, 255, 1)">goto</span> <span style="color: rgba(128, 0, 0, 1)">:input</span> 

) else (


讯享网

<span style="color: rgba(0, 0, 255, 1)">for</span> /f "delims=" %%i in ('findstr "/c:-%code%" name.txt') <span style="color: rgba(0, 0, 255, 1)">do</span> ( <span style="color: rgba(0, 0, 255, 1)">set</span> "i=%%i" <span style="color: rgba(0, 0, 255, 1)">echo</span>. <span style="color: rgba(0, 0, 255, 1)">if</span> <span style="color: rgba(0, 0, 255, 1)">not</span> <span style="color: rgba(0, 0, 255, 1)">exist</span> %<span style="color: rgba(0, 0, 255, 1)">cd</span>%%%i ( <span style="color: rgba(0, 0, 255, 1)">echo</span> Create folder ... <span style="color: rgba(0, 0, 255, 1)">echo</span> folder name =<span style="color: rgba(0, 0, 0, 1)"> %%i </span><span style="color: rgba(0, 0, 255, 1)">mkdir</span> "%cd%%%i" <span style="color: rgba(0, 0, 255, 1)">echo</span><span style="color: rgba(0, 0, 0, 1)"> Create successful! </span>) <span style="color: rgba(0, 0, 255, 1)">else</span> ( <span style="color: rgba(0, 0, 255, 1)">echo</span> Create folder ... <span style="color: rgba(0, 0, 255, 1)">echo</span><span style="color: rgba(0, 0, 0, 1)"> This folder already exists! </span><span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(0, 0, 255, 1)">Do</span><span style="color: rgba(0, 0, 0, 1)"> you want to overwrite this folder ? </span><span style="color: rgba(0, 0, 255, 1)">echo</span> "Yes" Please press Enter Key to continue. <span style="color: rgba(0, 0, 255, 1)">echo</span> "NO" Please close this window. <span style="color: rgba(0, 0, 255, 1)">pause</span> &gt;<span style="color: rgba(0, 0, 0, 1)">nul </span>)  <span style="color: rgba(0, 128, 0, 1)">rem</span><span style="color: rgba(0, 128, 0, 1)"> 因为%%i中存在空格.传递参数时,会以空格为准,出现多个参数.</span> <span style="color: rgba(0, 128, 0, 1)">rem</span><span style="color: rgba(0, 128, 0, 1)"> call :rename %%i</span> <span style="color: rgba(0, 128, 0, 1)">rem</span><span style="color: rgba(0, 128, 0, 1)"> :move</span> <span style="color: rgba(0, 128, 0, 1)">rem</span><span style="color: rgba(0, 128, 0, 1)"> echo %1</span> <span style="color: rgba(0, 128, 0, 1)">rem</span><span style="color: rgba(0, 128, 0, 1)"> ---------------------------------------------------</span> <span style="color: rgba(0, 0, 255, 1)">call</span> <span style="color: rgba(128, 0, 0, 1)">:rename</span> <span style="color: rgba(128, 0, 0, 1)">:move</span> <span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(0, 0, 255, 1)">Rename</span><span style="color: rgba(0, 0, 0, 1)"> successful! </span><span style="color: rgba(0, 0, 255, 1)">del</span> "%cd% emp.txt" <span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(0, 0, 255, 1)">Move</span> <span style="color: rgba(0, 0, 255, 1)">files</span> ... <span style="color: rgba(0, 0, 255, 1)">move</span> "%cd%*.png" "%cd%!i!" 1&gt;<span style="color: rgba(0, 0, 0, 1)">nul </span><span style="color: rgba(0, 0, 255, 1)">echo</span>. <span style="color: rgba(0, 0, 255, 1)">echo</span><span style="color: rgba(0, 0, 0, 1)"> It's OK </span><span style="color: rgba(0, 0, 255, 1)">goto</span> <span style="color: rgba(128, 0, 0, 1)">:end1</span> ) 

) rem ======================================================================== :rename adb devices|findstr “device$” 1&gt;nul 2&gt;nul if not %errorlevel%== 0 (

讯享网<span style="color: rgba(0, 0, 255, 1)">echo</span> Devices <span style="color: rgba(0, 0, 255, 1)">not</span><span style="color: rgba(0, 0, 0, 1)"> connected ! </span><span style="color: rgba(0, 0, 255, 1)">echo</span> Please check whether the USB is turned <span style="color: rgba(0, 0, 255, 1)">on</span>. <span style="color: rgba(0, 0, 255, 1)">goto</span> <span style="color: rgba(128, 0, 0, 1)">:end2</span> 

) echo Import screenshots into the current folder … rem You need to pay attention to the version of adb rem adb pull /sdcard/DCIM/Screenshots/ “%cd%” 1&gt;nul 2&gt;nul adb pull /sdcard/Pictures/Screenshots/ “%cd%” 1&gt;nul 2&gt;nul echo. ping 127.0.0.1 -n 3 &gt;nul if not exist %cd%^S*.*g (

<span style="color: rgba(0, 0, 255, 1)">echo</span><span style="color: rgba(0, 0, 0, 1)"> Import pictures failure ! </span><span style="color: rgba(0, 0, 255, 1)">echo</span> Please check the "allow the debug?" whether always allow?&amp;<span style="color: rgba(0, 0, 255, 1)">goto</span> <span style="color: rgba(128, 0, 0, 1)">:end2</span> 

) rem Count the number of pictures. for /f %%i in (’dir /b %cd%^S*.*g’) do (

讯享网<span style="color: rgba(0, 0, 255, 1)">set</span> /a a+=1 

) if %a% equ 9 (

<span style="color: rgba(0, 0, 255, 1)">echo</span><span style="color: rgba(0, 0, 0, 1)"> Successfully import %a% pictures ! </span><span style="color: rgba(0, 128, 0, 1)">rem</span><span style="color: rgba(0, 128, 0, 1)"> Modify code and Transfer new names to temp.txt</span> <span style="color: rgba(0, 0, 255, 1)">for</span> /f "eol=. delims=- tokens=2" %%j in (criterion.txt) <span style="color: rgba(0, 0, 255, 1)">do</span> ( <span style="color: rgba(0, 0, 255, 1)">set</span> "update=%code%_%%j" <span style="color: rgba(0, 0, 255, 1)">echo</span> !update!&gt;&gt;temp.<span style="color: rgba(0, 0, 0, 1)">txt </span>) <span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(0, 0, 255, 1)">Rename</span> <span style="color: rgba(0, 0, 255, 1)">files</span> ... <span style="color: rgba(0, 128, 0, 1)">rem</span><span style="color: rgba(0, 128, 0, 1)"> Using adb pull pictures is ascending sort </span> <span style="color: rgba(0, 128, 0, 1)">rem</span><span style="color: rgba(0, 128, 0, 1)"> Using /r or /f is descending sort (dir /b /od)</span> ( <span style="color: rgba(0, 0, 255, 1)">for</span> /r %<span style="color: rgba(0, 0, 255, 1)">cd</span>% %%k in (^S*.*g) <span style="color: rgba(0, 0, 255, 1)">do</span> (  <span style="color: rgba(0, 0, 255, 1)">set</span> /a b+=1 <span style="color: rgba(0, 0, 255, 1)">set</span> /p newName= <span style="color: rgba(0, 0, 255, 1)">echo</span> %%~nxk --^&gt;"!newName!.png" <span style="color: rgba(0, 0, 255, 1)">ren</span> %%~nxk "!newName!.png" <span style="color: rgba(0, 0, 255, 1)">if</span> !b! == %a% <span style="color: rgba(0, 0, 255, 1)">goto</span> <span style="color: rgba(128, 0, 0, 1)">:move</span> ))&lt;temp.<span style="color: rgba(0, 0, 0, 1)">txt 

) else (

讯享网<span style="color: rgba(0, 0, 255, 1)">if</span> %a% equ 10 ( <span style="color: rgba(0, 0, 255, 1)">echo</span><span style="color: rgba(0, 0, 0, 1)"> Successfully import %a% pictures ! </span><span style="color: rgba(0, 0, 255, 1)">for</span> /f "delims=- tokens=2" %%j in (criterion.txt) <span style="color: rgba(0, 0, 255, 1)">do</span> ( <span style="color: rgba(0, 0, 255, 1)">set</span> /a c+=1 <span style="color: rgba(0, 0, 255, 1)">if</span> !c! == 11 ( <span style="color: rgba(0, 0, 255, 1)">set</span> update="" ) <span style="color: rgba(0, 0, 255, 1)">else</span> ( <span style="color: rgba(0, 0, 255, 1)">set</span> update=<span style="color: rgba(0, 0, 0, 1)">%code%_%%j </span><span style="color: rgba(0, 0, 255, 1)">echo</span> !update!&gt;&gt;temp.<span style="color: rgba(0, 0, 0, 1)">txt </span>) ) <span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(0, 0, 255, 1)">Rename</span> <span style="color: rgba(0, 0, 255, 1)">files</span> ... ( <span style="color: rgba(0, 0, 255, 1)">for</span> /r %<span style="color: rgba(0, 0, 255, 1)">cd</span>% %%k in (^S*.*g) <span style="color: rgba(0, 0, 255, 1)">do</span> (  <span style="color: rgba(0, 0, 255, 1)">set</span> /a b+=1 <span style="color: rgba(0, 0, 255, 1)">set</span> /p newName= <span style="color: rgba(0, 0, 255, 1)">echo</span> %%~nxk --^&gt;"!newName!.png" <span style="color: rgba(0, 0, 255, 1)">ren</span> %%~nxk "!newName!.png" <span style="color: rgba(0, 0, 255, 1)">if</span> !b! == %a% <span style="color: rgba(0, 0, 255, 1)">goto</span> <span style="color: rgba(128, 0, 0, 1)">:move</span> ))&lt;temp.<span style="color: rgba(0, 0, 0, 1)">txt </span>) <span style="color: rgba(0, 0, 255, 1)">else</span> ( <span style="color: rgba(0, 0, 255, 1)">if</span> %a% equ 11 ( <span style="color: rgba(0, 0, 255, 1)">echo</span><span style="color: rgba(0, 0, 0, 1)"> Successfully import %a% pictures ! </span><span style="color: rgba(0, 0, 255, 1)">for</span> /f "delims=- tokens=2" %%j in (criterion.txt) <span style="color: rgba(0, 0, 255, 1)">do</span> ( <span style="color: rgba(0, 0, 255, 1)">set</span> update=<span style="color: rgba(0, 0, 0, 1)">%code%_%%j </span><span style="color: rgba(0, 0, 255, 1)">echo</span> !update!&gt;&gt;temp.<span style="color: rgba(0, 0, 0, 1)">txt </span>) <span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(0, 0, 255, 1)">Rename</span> <span style="color: rgba(0, 0, 255, 1)">files</span> ... ( <span style="color: rgba(0, 0, 255, 1)">for</span> /r %<span style="color: rgba(0, 0, 255, 1)">cd</span>% %%k in (^S*.*g) <span style="color: rgba(0, 0, 255, 1)">do</span> ( <span style="color: rgba(0, 0, 255, 1)">set</span> /a b+=1 <span style="color: rgba(0, 0, 255, 1)">set</span> /p newName= <span style="color: rgba(0, 0, 255, 1)">echo</span> %%~nxk --^&gt;"!newName!.png" <span style="color: rgba(0, 0, 255, 1)">ren</span> %%~nxk "!newName!.png" <span style="color: rgba(0, 0, 255, 1)">if</span> !b! == %a% <span style="color: rgba(0, 0, 255, 1)">goto</span> <span style="color: rgba(128, 0, 0, 1)">:move</span> ))&lt;temp.<span style="color: rgba(0, 0, 0, 1)">txt </span>) <span style="color: rgba(0, 0, 255, 1)">else</span> (<span style="color: rgba(0, 0, 0, 1)"> color 0d </span><span style="color: rgba(0, 0, 255, 1)">echo</span><span style="color: rgba(0, 0, 0, 1)"> Successfully import %a% pictures ! </span><span style="color: rgba(0, 0, 255, 1)">echo</span><span style="color: rgba(0, 0, 0, 1)"> The total number of pictures is error! </span><span style="color: rgba(0, 0, 255, 1)">echo</span> Please check the total number of pictures.&amp;<span style="color: rgba(0, 0, 255, 1)">goto</span> <span style="color: rgba(128, 0, 0, 1)">:end2</span> ) ) 

) rem ========================================================================= :end1 timeout /t 5 &goto :comment :end2 echo Please operate according to the prompt. timeout /t 10 &goto :comment pause


小讯
上一篇 2025-05-28 09:21
下一篇 2025-05-02 08:12

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/161138.html