Solved

What is this saying?

Posted on 2013-06-05
5
195 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
[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
  • Learn & ask questions
  • 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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