Solved

DOS Command - Parsing File on today's date

Posted on 2010-11-17
3
601 Views
Last Modified: 2012-05-10
I am trying to setup a DOS batch file to be able to run 7-zip on file in a folder.

I need to be able to run this 7-zip on today's date.

Example:

7-zip  filename "today's date"

How do I structure my script to only apply my 7-zip on Today's Date?
0
Comment
Question by:j4piper
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
Thommy earned 500 total points
ID: 34156517
7-zip  filename %DATE%

0
 
LVL 10

Expert Comment

by:jramsier
ID: 34156525
in command prompt you can add this to it: "%date:~10,4%-%date:~4,2%-%date:~7,2%"  it will create "2010-01-29"  Format it as you want.  You can move the 3 sections around to make a different format.
0
 
LVL 19

Expert Comment

by:Thommy
ID: 34156559
if you want to build your own date string...

check your date format by typing DATE

if your date format is for example 17/11/2010, you can built your own date string as follows


Set mm=%DATE:~3,2%
Set dd=%DATE:~0,2%
Set yyyy=%DATE:~6,4%

REM Built variable with own date format
set MyDate=%yyyy%-%mm%-%dd%

7-zip  filename %MyDate%

Open in new window

0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

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…
One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…

726 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