This approach has two advantages:
1, no matter when you can know what the photograph is. The date and time of the file, sometimes copied to another place, will change, I really have found such a situation. Name it by date and time, so you don't lose the time of the file!
2, will not repeat, also convenient to sort anything
But a change is too troublesome, on the internet to find a few software is not too convenient, so with batch processing their own, feel very good.
debugging and debugging, not perfect ... Although it is a small function, but to be perfect a little ... It's a waste of time!
Finally finished, since think the function is very powerful, and very perfect ~ ~ Thought of the function are added, think of the mistakes are also ruled out ...
Although it is intended to modify the photograph, it is absolutely applicable to the modification of any document ...
Welcome to download and use, welcome correct exchange!
Download Address: Chgname_jb51net.rar
Main function Introduction:
This program will batch name the specified file in the specified folder (the file supports wildcard characters) and will copy the file to the specified directory to modify the name when executed.
1, by default, rename to: [File date Time + serial number]
2, you can also keep the original file name, this time without serial number: [File date Time + original filename]
3, you can also specify a filename, at which time the file is renamed: [Specify filename + ordinal] or [specify filename + original filename]
4, the above situation is controlled with 5 parameters, it is convenient to use.
5, add the Help function, and change it again, so that others can understand, the full use of this program.
6, to join the debugging function, general errors are prompted.
Program Help as follows:
Help:
-----------------------------------------
This program can modify the file name in batches, by default, change the file name to [file date time + ordinal], or you can specify a filename, modify the filename to [specify filename + ordinal], and keep the original file name.
Usage Chgname.bat [parameter 1: file] [parameter 2: Source directory] [parameter 3: target directory] [parameter 4: Keep original filename] [parameter 5: Specify filename]
Description
Parameter 1: File to modify name, support 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 where the file is renamed, and if there is no directory, the program will automatically create the directory
Parameter 4: Whether to keep the original filename--not necessary parameters: When setting this parameter =y, keep the original file name (no ordinal in the name); When this parameter is =n, the original file name is not preserved, and the sequence number is appended to the name.
Parameter 5: Set a specific file name--not necessary parameter: When setting this parameter, the [parameter 5+ ordinal/original filename] is named, when not set, with [date time + serial number/original filename] of the file.
Attention
1, the parameter 1~3 must fill the parameter, cannot be empty!
2, the directory must end with a slash "\"
3, the source directory and the target directory cannot be the same directory
4, the target directory if it does not exist, the program will automatically create a directory
Furthermore
Parameter 1=version, display program version (VERSION=VER=V)
Parameter 1=help, display program Help (help=h=?)
Example
Chgname.bat *.jpg d:\photo\ d:\new\
Processes the *.jpg file in the folder d:\photo\, copies to the directory d:\new\, does not keep the original file name, according to [File date time + serial number] name.
Chgname.bat *.jpg d:\photo\ d:\new\ Y
Process the *.jpg file in the folder d:\photo\, copy it to the directory d:\new\, keep the original file name, and name it by [date time + original filename] of the file.
Chgname.bat 10*.jpg d:\photo\ d:\new\ N 20100910
Process the 10*.jpg file in the folder d:\photo\, copy it to the directory d:\new\, do not keep the original filename, and name it by [20100910+ serial number].
Chgname.bat 10*.jpg d:\photo\ d:\new\ Y 20100910
Process the 10*.jpg file in the folder d:\photo\, copy it to the directory d:\new\, keep the original file name, and name it by [20100910+ original filename].
The main code is as follows:
Copy Code code as follows:
@echo off
Setlocal enabledelayedexpansion
Echo.
:: Echo parameter:%1,%2,%3,%4
echo copies file% 1 in directory [%2] to directory [%3] and names the file date ...
Echo.
The echo---processed as follows---
Echo.
:: If the target directory does not exist, create
If not exist%3 (
Echo.
The Echo target directory [%3] does not exist, is being created ...
MD%3
echo--The target directory was created successfully!
Echo.
)
Set pno=0
For/r%2%%i in (% 1) do (
Set Pftime=%%~ti
if/i {%5}=={} (
:: Named after the date time of a file
Set pfnewname=!pftime:~0,4!! pftime:~5,2!! pftime:~8,2!_!pftime:~11,2!! pftime:~14,2!
) Else (
:: Named with any name
Set pfnewname=%5
)
set/a pno=!pno!+1
if/i "%4" = = "Y" (
Copy%%i%3!pfnewname!_%%~nxi
Echo!pno! %%~nxi-%%~ti renamed!pfnewname!_%%~nxi
) Else (
Copy%%i%3!pfnewname!_!pno!%%~xi
Echo!pno! %%~nxi-%%~ti renamed!pfnewname!_!pno!%%~xi
)
)
Finally, to despise the Lenovo mobile phone program designers, with that shot of the photo is also named by the date and time, but this ya only took the date and time, omitted the year and month, such as 10/8th shot, named 081230.jpg, really don't know how to think, save so little things to do ... Are you urging us to tidy up every day!
And the software features, folder settings, too bad!
In a word: too rubbish ...
PS: Attached program to run the example ~
D:\>chgname *.jpg d:\myTemp\11\ d:\mytemp\new\
"Welcome to use the file Batch name program/chgname.bat_v1.0.0.1 by Taoether"
Copy the file in the directory [d:\myTemp\11\] *.jpg to the directory [d:\mytemp\new\] and modify the file
Name......
---processed as follows---
The target directory [d:\mytemp\new\] does not exist and is being created ...
--The target directory was created successfully
1 files have been copied.
1 231759.JPG-2010/09/23 17:59 renamed to 20100923_1759_1.jpg
1 files have been copied.
2 23175902.JPG-2010/09/23 17:59 renamed to 20100923_1759_2.jpg
1 files have been copied.
3 photo 083.JPG-2010/09/23 18:17 renamed to 20100923_1817_3.jpg
1 files have been copied.
4 photo 085.JPG-2010/09/23 21:29 renamed to 20100923_2129_4.jpg
Please press any key to continue ...
D:\>chgname *.jpg d:\myTemp\11\ d:\mytemp\new\ Y
"Welcome to use the file Batch name program/chgname.bat_v1.0.0.1 by Taoether"
Copy the file in the directory [d:\myTemp\11\] *.jpg to the directory [d:\mytemp\new\] and modify the file
Name......
---processed as follows---
1 files have been copied.
1 231759.JPG-2010/09/23 17:59 renamed to 20100923_1759_231759.jpg
1 files have been copied.
2 23175902.JPG-2010/09/23 17:59 renamed to 20100923_1759_23175902.jpg
1 files have been copied.
3 photo 083.jpg-2010/09/23 18:17 renamed 20100923_1817_ photo 083.jpg
1 files have been copied.
4 photo 085.jpg-2010/09/23 21:29 renamed 20100923_2129_ photo 085.jpg
Please press any key to continue ...
D:\>chgname 23*.jpg d:\myTemp\11\ d:\mytemp\new\ N 20100923
"Welcome to use the file Batch name program/chgname.bat_v1.0.0.1 by Taoether"
Copy the files in the directory [d:\myTemp\11\] 23*.jpg to the directory [d:\mytemp\new\] and modify the text
Part name ...
---processed as follows---
1 files have been copied.
1 231759.JPG-2010/09/23 17:59 renamed to 20100923_1.jpg
1 files have been copied.
2 23175902.JPG-2010/09/23 17:59 renamed to 20100923_2.jpg
Please press any key to continue ...
D:\>chgname 23*.jpg d:\myTemp\11\ d:\mytemp\new\ Y 20100923
"Welcome to use the file Batch name program/chgname.bat_v1.0.0.1 by Taoether"
Copy the files in the directory [d:\myTemp\11\] 23*.jpg to the directory [d:\mytemp\new\] and modify the text
Part name ...
---processed as follows---
1 files have been copied.
1 231759.JPG-2010/09/23 17:59 renamed to 20100923_231759.jpg
1 files have been copied.
2 23175902.JPG-2010/09/23 17:59 renamed to 20100923_23175902.jpg
Please press any key to continue ...
D:\>