其实楼主的问题用第三方的更名软件(例如拖把更名器),甚至用Windows的资源管理器和acdsee等都可以很容易的实现。但既然楼主要求使用命令行,下面就给出几个办法。
一时想不到不用第三方工具该如何做,先给出一个使用第三方工具lmod的办法:
@echo off
lmod > nul
dir /b *.* | lmod /L* ren "" abc.jpg > %temp%\temp.bat
call %temp%\temp.bat
del %temp%\temp.bat
在写这个批处理的时候,突然又想到了一个不用第三方工具的方法:
@echo off
:: 要求你的文件名中必须含有jpg这个扩展名
dir /b | find /n /i "jpg" > %temp%\temp.txt
for /f "delims= tokens=1,*" %%i in (%temp%\temp.txt) do ren "%%j" abc%%i.jpg && echo Rename "%%j" to "abc%%i.jpg"
del %temp%\temp.txt
In fact, the owner's problem can be easily achieved using third-party renaming software (such as Tuoba Renamer), or even using Windows Explorer and ACDSee, etc. But since the owner requires using the command line, the following are several methods.
For a while, I can't think of how to do it without using third-party tools, so first give a method using the third-party tool lmod:
@echo off
lmod > nul
dir /b *.* | lmod /L* ren "" abc.jpg > %temp%\temp.bat
call %temp%\temp.bat
del %temp%\temp.bat
When writing this batch processing, I suddenly thought of a method without using third-party tools:
@echo off
:: It is required that your file name must contain the jpg extension
dir /b | find /n /i "jpg" > %temp%\temp.txt
for /f "delims= tokens=1,*" %%i in (%temp%\temp.txt) do ren "%%j" abc%%i.jpg && echo Rename "%%j" to "abc%%i.jpg"
del %temp%\temp.txt