Solved

What is this saying?

Posted on 2013-06-05
5
193 Views
Last Modified: 2013-06-05
I am working a batch file that will get a count of all of the files in a folder that are 25 days old and newer. After internet searching I have found this:
setlocal
set "dd=%date:~0,2%"
set "mm=%date:~3,2%"
set "yy=%date:~-2%"
xcopy * /H /L /S /Q /Y /d:%mm%-%dd%-%yy%

My question is what does the numbers 0,2%, 3,2% & 2% indicate?
Thank you in advance for the education.
Lori
0
Comment
Question by:NLITech
  • 3
5 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 39222635
They are the positional arguments of the variable %date%.

So, if you type
echo %date%
You will get back either the day abbreviation, and the date (depending on your regional settings), or just the date.

If the result is 06/06/2013, then dd will be equivalent to (starting at the first, cardinally zero position): "06".
mm would skip positions 0, 1 & 2 ("06/") and be assigned to the month ("06") with yy being set to the last two digits of the year (the dash states to count from the right side, stepping two positions backwards).
0
 

Author Closing Comment

by:NLITech
ID: 39222642
Thank you!!
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 39222644
Here's another example.  Assign variable "Food" to be value "Grapes".
Then show the first 2 characters, "Gr", the next two beginning at position 3, "pe", and finally the last 2 characters "es".

set Food=Grapes
echo %Food:~0,2%
result>>  Gr

echo %Food:~3,2%
result>> pe

echo %Food:~-2%
result>> es
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 39222647
Happy to help - thanx for the grade! :^)
0
 
LVL 26

Expert Comment

by:pony10us
ID: 39222650
0,2 = starting at position 0 get the next two characters in the string (1 and 2)

3,2 = starting at position 3 get the next two characters in the string (4 and 5)

-2 = starting at the right of the string get the previous 2 characters

So based on the description this would be the European style date?

05/06/2013  

0,2 = 05 (dd)

3,2 = 06 (mm)

-2 = 13 (yy)


Day late and dollar short as usual.   :)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question