Solved

What is this saying?

Posted on 2013-06-05
5
190 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now