
批處理根據指定文本列出的新舊文件名對照列表批量重命名文件最后由 pcl_test 于 -7-4 10:34[新手現丑了,如有不足,還請指點]對應表格: list.txt(,前面為舊名,后面為新名稱)(實際上是無數個文本)111111,32srfsdfa222222,dff3afsaf33333,rg4xvdzv444444,wew34fsd5555555,rtgfgxfbgd當前文件夾有如下文本,需要依照以上對應表自動改名。(實際上是無數個文本)111111.txt222222.txt33333.txt444444.txt5555555.txt[原創代碼]:
[具體說明]:1.剛開始按[y] enter key 可以備份原來的所有的txt文本(自動創建文件夾Backup0628123320)2. 對應表里面,沒有更改到的文件,會以類似Log_0628123320.txt檔來記錄。nclick="copycode($('code0'));">復制代碼
- @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

