Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 608
  • Last Modified:

DOS Command - Parsing File on today's date

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
j4piper
Asked:
j4piper
  • 2
1 Solution
 
ThommyCommented:
7-zip  filename %DATE%

0
 
jramsierCommented:
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
 
ThommyCommented:
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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now