@echo off::---------------------------------------------------------------------------------------------------- ----User parameter Assignment----------------------: whether to delete the original task (note: If it is set to Y, it will delete all scheduled tasks of the system, please set it carefully) set Pdelflag=n:: Please set the shutdown delay hours set pdefhour=1 :: Please set shutdown delay minutes set pdefminute=0::--------------------------------------------------------------------------------- -----------------------System parameter Assignment----------------------set xpprogname= file batch renaming program set Xpfilename=chgname.batset xpauthor= Taoetherset Xpprogver=1.0.0.1set Xpsupport=http://www.taoyoyo.net/ttt/post/458.htmlset [Email protected]set Xpmode=aset xpdebug_flag=0:: Set color scheme:: xpcolordef--program Default color configuration 3e::xpcolorerr--program error when color configuration, e4::xpcoloroth--other colors, such as help, Version information 3f::xpcolor1,xpcolor2--custom colors for each program:: Default scheme--------3e,84,3fset xpcolordef=30set xpcolorerr=84set xpcoloroth=3fset Xpcolor1=30set xpcolor2=f4goto lblinitialize::------------------------------------------------------------------ --------------------------------------Program Description-------------------------:: This paragraph is commented::: Batch Renaming program, you can change the file name in batch toFile date + FileName:: Need to add Parameters: 1, file, 2, source directory, 3, target directory, 4, whether with the original file name, 5, specify the file name:: Cannot operate in the same directory, it is possible to repeat the modification ...:: chgname *.jpg D:\MyTemp\PHOTO d:\ Photo--Change D:\MyTemp\PHOTO under *.jpg name, save to D:\photo\*.jpg::--------------------------------------------------------- -----------------------------------------------System initialization-------------------------: Lblinitialize goto lblstart::----- ---------------------------------------------------------------------------------------------------Environment Setting subroutine--------------- -----:p rsetdisplay:: CLS color%1:: Mode con lines=%2 cols=%3 title Welcome to%xpprogname%/%xpfilename%_v%xpprogver % [by%xpauthor%] echo. echo "Welcome to%xpprogname%/%xpfilename%_v%xpprogver% by%xpauthor%" Rem Echo Welcome to the!xpauthor! compiled!xpprogname! (!xpfilename!) !xpprogname!_v!xpprogver! Echo. :: Echo Current program run mode =[%xpmode%]goto:eof::--------------------------------------------------------------------------- -----------------------------Program Judge-------------------------: Lblstart if/i "%1" = = "Version" goto lblver if/i "%1" = = "Ver" goto lblver if/i "%1" = = "V" goto lblver if/i {%1}=={help} goto lblhelp if/i "%1" = = "H" goto Lblhelp if/i {%1}=={h} goto lblhelp if/i {%1}=={} goto lblhelp if {%1}=={} goto lblerror if {%2}=={} goto Lblerror if {%3}=={} goto lblerror if {%2}=={%3} goto lblerror if not exist%2 goto lblerror goto lblmain::-- ------------------------------------------------------------------------------------------------------Help----------------- --------: Lblhelp call:p Rsetdisplay%xpcoloroth% echo. echo Help:echo-----------------------------------------echo This program can modify the file name in bulk, by default the file name is modified to [File date time + serial number], you can also specify a file name, modify the file name to [specify File name + serial number]; The original file name can also be preserved. :: Batch Renaming program, you can change the file name to the files date + FileName:: Need to add Parameters: 1, file, 2, source directory, 3, target directory, 4, whether with the original filename "" 〖〗echo. echo "Usage"%xpfilename% [parameter 1: file] [parameter 2: Source directory] [parameter 3: target directory] [parameter 4: Preserve original filename] [parameter 5: Specify FileName] echo. echo "description" echo Parameter 1: To modify the name of the file, support wildcard characters, such as *.jpg, 10*.jpg echo Parameter 2: Source directory--the directory where you want to rename the file echo Parameter 3: Target directory--file after renamingDirectory, if you do not have this directory, the program will automatically create the directory echo parameter 4: whether to retain the original file name--unnecessary parameters: When setting this parameter =y, the original file name is preserved (no ordinal in the name); When this parameter =n, the original file name is not preserved, and the ordinal is added to the name. Echo parameter 5: Set a specific file name--unnecessary parameter: When setting this parameter, the [parameter 5+ ordinal/original file name] is named; when not set, the [File date time + ordinal/original file name] is named. Echo. echo "Note" Echo 1, parameter is required parameter, cannot be empty! Echo 2, the directory must finally have a slash "\" Echo 3, the source directory and destination directory cannot be the same directory echo 4, the target directory if it does not exist, the program will automatically create the directory echo. echo "Additionally" echo parameter 1=version, display program version (VERSION=VER=V) echo parameter 1=help, display program Help (help=h=?) Echo. echo "Example" Echo%xpfilename% *.jpg d:\photo\ d:\new Echo handles d:\photo\ file in folder *.jpg, copy to directory d:\new\, do not retain the original file name, press [text The date time + serial number of the item) is named. echo%xpfilename% *.jpg d:\photo\ d:\new\ Y echo process d:\photo\ file in folder *.jpg, copy to directory d:\new\, keep the original file name, press [File date time + original filename] Named. echo%xpfilename% 10*.jpg d:\photo\ d:\new\ N 20100910 echo handles d:\photo\ files in folder 10*.jpg, copy to directory d:\new\, do not retain the original file name, press [20100910+ serial number] named. echo%xpfilename% 10*.jpg d:\photo\ d:\new\ Y 20100910 echo process d:\photo\ file in folder 10*.jpg, copy to directory d:\new\, keep the original file name, press [ 20100910+ OriginalFileName] named. Echo. echo "Related notes"%xpsupport% echo "technical support"%xpemail% echo-----------------------------------------call:lbladgoto lb LEnd::-------------------------------------------------------------------------------------------------------- Version-------------------------: Lblver call:p Rsetdisplay%xpcoloroth% echo. REM Important statement: REM This program is written by Tauyongli, you can spread it arbitrarily, but please do not delete the following information! For commercial use of REM, please contact the author. echo Version:echo------------------------------Echo Program:%xpprogname%/%xpfilename% Echo Author:%xpauthor% echo Version:%xpprogver% echo issuetime:20100526 echo updatetime: echo Email:%xpemail% echo Blog:http://www.taoyoyo.net/ttt/echo Homepage:http://www.tao Yoyo.net/echo------------------------------Echo. echo Version Log:echo-----------------------------------------echo Ver. Date. Log. Echo-----------------------------------------Echo V1000 20100526 New program issue. echo V1001 20101010 Optimize program echo. echo ... echo-----------------------------------------echo related description:%xpsupport% echo Technical support:%xpemail% call : Lbladgoto lblend::-------------------------------------------------------------------------------------------- ------------error Handling-------------------------: Lblerror call:p Rsetdisplay%xpcolorerr% echo. :: echo "Related Notes"%xpsupport%:: echo "Technical Support"%xpemail%:: Echo-related instructions:%xpsupport% technical support:%xpemail%: : echo-related instructions:%xpsupport% technical support:%xpemail% echo "program error" echo. if {%1}=={} (the echo parameter is insufficient!) Echo. Echo This command requires three required parameters: Echo [parameter 1: file] echo [parameter 2: Source directory] echo [parameter 3: Target directory] Echo There is also an optional parameter: Echo [parameter 4: Whether to retain the original filename] echo [parameter 5: Specify the filename] echo. echo Please type [%xpfilename% H] to see the help information echo. Echo--related instructions:%xpsupport% echo--Technical support:%xpemail% goto lblend) if {%2}=={} (the echo parameter is insufficient!) Echo. Echo This command requires three required parameters: Echo [parameter 1: file] echo [parameter 2: Source directory] echo [parameter 3: Target directory] Echo There is also an optional parameter: Echo [parameter 4: Whether to retain the original filename] echo [parameter 5: Specify the filename] echo. echo Please type [%xpfilename% H] to see the help information echo. echo-related instructions:%xpsupport% echo-Technical support:%xpemail% goto lblend) if {%3}=={} (Echo Insufficient Parameters! Echo. Echo This command requires three required parameters: Echo [parameter 1: file] echo [parameter 2: Source directory] echo [parameter 3: Target directory] Echo There is also an optional parameter: Echo [parameter 4: Whether to retain the original filename] echo [parameter 5: Specify the filename] echo. echo Please type [%xpfilename% H] to see the help information echo. echo-related instructions:%xpsupport% echo-Technical support:%xpemail% goto lblend) if/i {%2}=={%3} (Ech O parameter Error! Echo. Echo Source directory and TargetThis will cause duplicate naming, modify the parameters. Echo. echo Please type [%xpfilename% H] to see the help information echo. echo-related instructions:%xpsupport% echo-Technical support:%xpemail% goto lblend) if not exist%2 (echo SOURCE Directory Error! Echo. The echo source directory [%2] does not exist, please check and re-enter. Echo. echo Please type [%xpfilename% H] to see the help information echo. echo-Related notes:%xpsupport% echo-Technical support:%xpemail% goto Lblend) echo. Goto lblend::-------------------------------------------------------------------------------------------------- ------AD-------------------------: Lblad echo. :: Echo----------echo "Little ad": Echo----------Echo This profile is provided by long net, TTT blog, Welcome to visit! echo [leisurely net] http://www.taoyoyo.net/echo [TTT BLOG] Http://www.taoyoyo.net/ttt/echo Contact us: [Email pro Tected]goto:eof ====== Below is the advertising time ~~====== This information is provided by leisurely nets, welcome to visit leisurely network: http://www.taoyoyo.net/leisurely network, carefully for everyone to collect and organize the network resources! Welcome to--[novel] http://www.taoyoyo.net/maoni/ Specially collect and tidy the works, ensure the original, there are preface, update time, all hand-edited, easy to read and collection, and activate WAP function (mobile reading), as well as mail, RSS subscription Function! [Fishy Forum] http://www.taoyoyo.net/mao/here is the home of the Fishy fans, is a forum that is organized spontaneously by the Fishy fans, specializes in the novel, and collects all kinds of cat news, works! [Classic games] http://www.taoyoyo.net/mgame/collection of classic games, absolutely classic, not classic collection, can be downloaded, can play online, and there are game instructions, tips, experience! [My resources] Http://www.taoyoyo.net/cpost/res/res_home.ASP collection of classic novels, learning materials, fine software and so on. [TTT Blog] http://www.taoyoyo.net/ttt/my blog, life drip, experience, hope to share with more friends! (Focus on Oracle,delphi,java,linux,unix, as well as website knowledge!) [YOYO Blog] http://www.taoyoyo.net/yoyo/daughter's blog, record my baby daughter's life drip, instant, leave good memories! [Leisurely Digest] http://www.taoyoyo.net/lib/leisurely weekly website, carefully collect and organize fine abstracts, and release free E-magazine < leisurely weekly > contact us: [email protected]::--------- -----------------------------------------------------------------------------------------------temporarily Save the code-------------------- -----:: Keep The original file name:: Copy%%i%3!pfnewname!_%%~nxi:: Do not retain the original file name:: Copy%%i%3!pfnewname!%%~xifor/r%2%%i in (% 1) d O (set Pftime=%%~ti set pfnewname=!pftime:~0,4!! pftime:~5,2!! pftime:~8,2!_!pftime:~11,2!! PFTIME:~14,2! set/a pno=!pno!+1 if/i "%4" = = "Y" (copy%%i%3!pfnewname!_%%~nxi echo!pno!%%~nxi-%%~ti renamed!pfnewna Me!_%%~nxi) if/i not "%4" = = "Y" (copy%%i%3!pfnewname!_!pno!%%~xi echo!pno!%%~nxi-%%~ti renamed !PFNEWNAME!_!PNO!%%~XI))::------------------------------------------------------------------------------------ --------------------Main program-------------------------: Lblmain call:p rsetdisplay%xpcolordef% @echo offsetlocal Enabledelayedexpansionecho.::echo parameter:%1,%2,%3,%4echo copy the file in directory [%2]% 1 to directory [%3], and modify the file name ... echo.echo---handle the following---echo.: : If the target directory does not exist, create if not exist%3 (echo target directory [%3] does not exist, creating ... MD%3 echo--target directory creation succeeded! echo.) Set pno=0for/r%2%%i in (% 1) does (set Pftime=%%~ti if/i {%5}=={} (:: Named set Pfnewname=!pfti with the date time of the file me:~0,4!! pftime:~5,2!! pftime:~8,2!_!pftime:~11,2!! pftime:~14,2! Else (:: Name the set pfnewname=%5 as any) set/a pno=!pno!+1 if/i "%4" = = "Y" ( Copy%%i%3!pfnewname!_%%~nxi Echo!pno! %%~nxi-%%~ti renamed to!pfnewname!_%%~nxi) Else (copy%%i%3!pfnewname!_!pno!%%~xi echo!pno!%%~nxi-%%~t I renamed to!pfnewname!_!pno!%%~xi) Goto lblend::--------------------------------------------------------------------- -----------------------------------End of program-------------------------: Lblendecho.pause
debugging and debugging, not perfect ... It's a waste of time! Finally finished, since the function is very powerful, and very perfect ~ ~ ~ Think of the functions are added, think of the errors are also excluded ... Although it is for the sake of modifying the photograph, it is absolutely applicable to modify any file ... Welcome to use, please correct me! Main Features: This program will batch name the specified file in the specified folder (the file supports wildcard characters), the execution will copy the file to the specified directory to modify the name. 1, by default, renamed to: [File date Time + serial number] 2, you can also keep the original file name, without the ordinal: [File date Time + original filename] 3, you can also specify a file name, at which time the files are renamed: [Specify the file name + ordinal] or [specify the filename + the original filename] 4, the above situation is controlled by 5 parameters, it is convenient to use. 5, add Help function, and change again, in order to let others get started to understand, fully use this program. 6, add the troubleshooting function, general errors are prompted. : http://down.qiannao.com/space/file/taoether/-4e0a-4f20-5206-4eab/-8f6f-4ef6-5de5-5177/ChgName.rar/.page====== ============= program Help =================== "Welcome to File batch Renaming program/chgname.bat_v1.0.0.1 by Taoether" helps:------------------------ -----------------This program can modify the file name in bulk, the file name is modified by default to [File date time + serial number], you can specify the file name, the file name is modified to [specify the file name + serial number], also can retain the original file name. "Usage" Chgname.bat [parameter 1: file] [parameter 2: Source directory] [parameter 3: target directory] [parameter 4: Preserve original file name] [parameter 5: Specify filename] "description" Parameter 1: File to modify name, wildcard characters, such as *.jpg, 10*.jpg parameter 2: source Directory-the directory where you want to rename the file parameter 3: Target directory-the directory after renaming the file, if not, the program will automatically create the directory parameter 4: whether to retain the original file name--unnecessary parameters: When the parameter =y is set, the original file name is reserved (no ordinal in the name); When this parameter =n, The original file name is not preserved, and an ordinal is added to the name. Parameter 5: Set specific file name--unnecessary parameter: When setting this parameter, name [parameter 5+ ordinal/original filename], not set to [file'sDate Time + ordinal/original filename] name. "Note" 1, parameters are required parameters, can not be empty! 2, the directory must finally have a slash "\" 3, the source directory and destination directory cannot be the same directory 4, the target directory if not present, the program will automatically create the directory "in addition" parameter 1=version, display the program version (version=ver=v) parameter 1=help, display the program to help Help (help=h=?) "Example" Chgname.bat *.jpg d:\photo\ d:\new The d:\photo\ file in the folder *.jpg, copied to the directory d:\new\, does not retain the original file name, press [File date Time + Serial number] named. Chgname.bat *.jpg d:\photo\ d:\new\ Y handles the d:\photo\ file in the folder *.jpg, copies it to the directory d:\new\, retains the original file name, and is named by [File date time + original filename]. Chgname.bat 10*.jpg d:\photo\ d:\new\ N 20100910 Process the d:\photo\ file in the folder 10*.jpg, copy to the directory d:\new\, do not retain the original file name, by [20100910+ serial number] named. Chgname.bat 10*.jpg d:\photo\ d:\new\ Y 20100910 Process the d:\photo\ file in the folder 10*.jpg, copy to the directory d:\new\, leave the original file name, and name it by [20100910+ original filename]. "Related instructions" http://www.taoyoyo.net/ttt/post/458.html "technical Support" [email protected]------------------------------------ -----This information by the long network to provide, welcome to visit leisurely network: http://www.taoyoyo.net/leisurely network, meticulously for everyone to collect and organize the network resources! Welcome to-[TTT blog] http://www.taoyoyo.net/ttt/my blog, life drip, experience, hope to share with more friends! (Focus on Oracle,delphi,java,linux,unix, as well as website knowledge!) [YOYO BLOG] http://www.taoyoyo.net/yoyo/womenSon's blog, record my baby daughter's life drip, instant, leave good memories! [Leisurely Digest] http://www.taoyoyo.net/lib/leisurely weekly website, carefully collect and organize fine abstracts, and issue free E-magazine < leisurely weekly > [novel] http://www.taoyoyo.net/maoni/ Door collection and collation of the works, to ensure the original, have preface, update time, all hand-edited, easy to read and collection, and activate WAP function (mobile reading), as well as mail, RSS subscription Function! [Fishy Forum] http://www.taoyoyo.net/mao/here is the home of the Fishy fans, is a forum that is organized spontaneously by the Fishy fans, specializes in the novel, and collects all kinds of cat news, works! [My resources] Http://www.taoyoyo.net/cpost/res/res_home.ASP collection of refined learning materials, videos, games, novels and other materials contact us: [email protected]
Batch modification file name worth Learning