LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices

Reply
 
Search this Thread
Old 08-02-2005, 10:45 AM   #1
deoren
Member
 
Registered: Oct 2003
Location: USA
Distribution: Ubuntu
Posts: 214

Rep: Reputation: 30
set TODAY=date "+%m%d%y"


Hi all,

I'm trying to write a batch script for a Windows 2000 Server system that assigns a variable the results of running a Win32 port of date.

Any ideas?

The equivalent way of accomplishing this in bash is

Code:
TODAY=`date "+%m%d%y"`
I'm just clueless on how to accomplish this in Windows land.

Thanks.
 
Old 08-02-2005, 11:45 AM   #2
Kdr Kane
Member
 
Registered: Jan 2005
Distribution: SUSE, LFS
Posts: 357

Rep: Reputation: 30
@echo off
@set TODAY=%DATE%
@echo %TODAY%


will do it. Or simply use %DATE% instead.

@echo %DATE%
 
Old 08-02-2005, 12:02 PM   #3
deoren
Member
 
Registered: Oct 2003
Location: USA
Distribution: Ubuntu
Posts: 214

Original Poster
Rep: Reputation: 30
Thanks for the reply. Is there anyway to get it in MMDDYY format? I'm using the date in MMDDYY format as the suffix for the tarball + md5 files.

I tried to catch the output from the Win32 native date binary but it doesn't seem to work that way.

Here is a snippet of the script

Code:
:: --------------------------------------------
:: Get date in a format we want to use
:: --------------------------------------------
REM set MONTH=date /T | cut -c 5-6
REM set DAY=date /T | cut -c 5-6
REM set YEAR=date /T | cut -c 13-14
REM set today=%MONTH%%DAY%%YEAR%

:: --------------------------------------------
::  We're setting it manually for right now.
:: --------------------------------------------
set today=072905



:: --------------------------------------------
:: create the tarball
:: --------------------------------------------
tar cf blackboard6p1-%today%.tar ./blackboard6p1
 
Old 08-02-2005, 12:05 PM   #4
Kdr Kane
Member
 
Registered: Jan 2005
Distribution: SUSE, LFS
Posts: 357

Rep: Reputation: 30
Not with batch commands.

You'll need to switch to VBScript.
 
Old 08-02-2005, 12:08 PM   #5
Kdr Kane
Member
 
Registered: Jan 2005
Distribution: SUSE, LFS
Posts: 357

Rep: Reputation: 30
http://www.experts-exchange.com/Prog..._20958124.html

Scroll down to the bottom of the page for the answers.
 
Old 08-02-2005, 12:14 PM   #6
deoren
Member
 
Registered: Oct 2003
Location: USA
Distribution: Ubuntu
Posts: 214

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by Kdr Kane
Not with batch commands.

You'll need to switch to VBScript.
No Perl, Python?

Oh well. Thanks for the link. I'll come up with a Perl or Python equivalent and post back when I figure it out.

Thanks again.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set the size of icons for "Starterbar" in "Gdekslets" Blue Jacket Linux - Software 4 11-23-2005 02:42 AM
Has your motherboard or hardware device been "Cracker Flash-Trashed" today? t3gah Linux - Security 11 06-14-2005 12:52 AM
"computers that are thousands of times more powerful than those that exist today." rksprst General 12 02-03-2005 07:25 PM
News: "Today the mydoom virus made the homepage of Linux unaccessible" J_Szucs General 31 02-09-2004 10:37 PM
Monthly Archiving Script... help with "date" & "cron" Supp0rtLinux Linux - Software 3 01-03-2003 09:29 PM


All times are GMT -5. The time now is 03:50 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration