AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
![]() However, instead of using the forward slash and space to break up the data, we're using a : ( colon) because the time uses this character. This command is very similar to the above example. Time for /f "tokens=1-5 delims=:" %%d in ("%time%") do rename "hope.txt" %%d-%%e.txt In this example, using the above date mentioned hope.txt would be renamed to 09-02-2007.txt. When %date% is used in a batch file, it displays the date in the following format: Sun. ![]() This example also has a - ( hyphen) in-between each token to separate the month, day, and year in the file name. rename "hope.txt" %%e-%%f-%%g.txt - Rename the file "hope.txt" to the tokens e,f, and g with a.The rename command can be substituted for anything else. in ("%date%") - The data, which is the %date% (date) of the computer.Since there are 5 tokens in this example it would be d,e,f,g, and h. %%d - The beginning character used for the token. ![]() Delims is short for delimiters and break up the date in this example, the / ( forward slash) and a space (space before the quote). "tokens=1-5 delims=/ " - How many tokens the incoming data (the date) will be broken into 1-5 is five different tokens.for /f - The for command and the /f switch.Date for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "hope.txt" %%e-%%f-%%g.txtīelow is a breakdown of the above command and what it all means. Each of the for commands listed in this page would be placed into a batch file. The example below shows how you can use the date command in the for command to extract the current date and use that data to rename the file. ![]() ![]() There are a few different methods of how this can be done. ![]()
0 Comments
Read More
Leave a Reply. |