Solved

datetime stamp

Posted on 2004-10-19
2
711 Views
Last Modified: 2008-02-26
Utilizing wzzip, how would I write a script that plugs a system datetime stamp on the zip file name?

For example,

"c:\Program Files\WinZip\WZZIP.EXE" c:\docs<datetime stamp>.zip c:\*.doc

would produce:

c:\docs10-19-2004 03:00.zip
0
Comment
Question by:arichexe
[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
2 Comments
 
LVL 7

Expert Comment

by:msice
ID: 12352928
For this you will need a .vbs WSH script like so it will create the zip file for you.

'VBScript

DIM fso, NewsFile, oFS
  var = cSTR(now())
  var = replace(var, "/" , "-" )
  var = replace(var, ":" , "_" )
  var = replace(var, "  " , "~" )
Set fso = CreateObject("Scripting.FileSystemObject")
Set NewsFile = fso.CreateTextFile("c:\docs"&var&".zip", True)
NewsFile.Close
0
 
LVL 96

Accepted Solution

by:
Lee W, MVP earned 250 total points
ID: 12353644
No need to use VBscript - you can do the same in effectively one line of a batch script:

for /f "tokens=2,3,4 delims=/ " %%a in ('date /t') do for /f "tokens=1,2,3 delims=: " %%m in ('time /t') do set filename=MyFileName%%a-%%b-%%c %%m%%n%%o

Note:
%%a = Month
%%b = Day
%%c = Year
%%m = Hour
%%n = Minute
%%o = AM or PM

Note, you can't use a colon (:) in a filename.

The above script effectively sets the variable filename (%filename%) to a name using the date and time code you request (although not in 24 hour format).  

To use in conjuction with your script that zips things, you'd do this:

----------------------------
for /f "tokens=2,3,4 delims=/ " %%a in ('date /t') do for /f "tokens=1,2,3 delims=: " %%m in ('time /t') do set filename=MyFileName%%a-%%b-%%c %%m%%n%%o
"c:\Program Files\WinZip\WZZIP.EXE" c:\%filename%.zip c:\*.doc
----------------------------
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
This article outlines the struggles that Macs encounter in Windows-dominated workplace environments – and what Mac users can do to improve their network connectivity and remain productive.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

635 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