
批處理根據(jù)指定文本列出的新舊文件名對(duì)照列表批量重命名文件最后由 pcl_test 于 -7-4 10:34[新手現(xiàn)丑了,如有不足,還請(qǐng)指點(diǎn)]對(duì)應(yīng)表格: list.txt(,前面為舊名,后面為新名稱)(實(shí)際上是無(wú)數(shù)個(gè)文本)111111,32srfsdfa222222,dff3afsaf33333,rg4xvdzv444444,wew34fsd5555555,rtgfgxfbgd當(dāng)前文件夾有如下文本,需要依照以上對(duì)應(yīng)表自動(dòng)改名。(實(shí)際上是無(wú)數(shù)個(gè)文本)111111.txt222222.txt33333.txt444444.txt5555555.txt[原創(chuàng)代碼]:
- @echo off
- echo ---------------------------------
- echo REPLACE ALL THE FILE NAMEs by LIST.TXT
- echo The format of LIST.TXT should be below;
- echo Old Name,New Name
- echo ---by S.J a freshman of programmer
- echo ---------------------------------
- echo Press [y] and Enter key to backup the files before replacing.
- echo Press [n] and Enter key If you want to replace without backup.
- echo Yes or no?
- set listfile=list.txt
- for /f tokens=2 delims== %%i in ('wmic path win32_operatingsystem get LocalDateTime /value ^| find =') do set datetime=%%i
- set now=%datetime:~,14%
- set input=
- set /p input=Please enter your choice[y/n]:
- :: Rename .txt and.pkg files
- for /f tokens=1,2 delims=, %%i in ('type %listfile%') do (
- if not exist %%i.txt (
- if not exist Log_%now%.txt echo;non-existent files:>Log_%now%.txt
- >>Log_%now%.txt echo;%%i_%%j
- ) else (
- if /i %input%==y (
- md Backup%now% 2>nul
- copy %%i.txt Backup%now%
- )
- ren %%i.txt %%j.txt
- )
- )
- cls
- if exist Log_%now%.txt type Log_%now%.txt
- pause
nclick="copycode($('code0'));">復(fù)制代碼
[具體說(shuō)明]:1.剛開(kāi)始按[y] enter key 可以備份原來(lái)的所有的txt文本(自動(dòng)創(chuàng)建文件夾Backup0628123320)2. 對(duì)應(yīng)表里面,沒(méi)有更改到的文件,會(huì)以類似Log_0628123320.txt檔來(lái)記錄。