Solved

# What is this saying?

Posted on 2013-06-05
Medium Priority
199 Views
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
Question by:NLITech
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3

LVL 67

Accepted Solution

sirbounty earned 2000 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

ID: 39222642
Thank you!!
0

LVL 67

Expert Comment

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

ID: 39222647
Happy to help - thanx for the grade! :^)
0

LVL 26

Expert Comment

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

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
###### Suggested Courses
Course of the Month11 days, 15 hours left to enroll