Solved

datetime stamp

Posted on 2004-10-19
2
706 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
2 Comments
 
LVL 7

Expert Comment

by:msice
Comment Utility
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 95

Accepted Solution

by:
Lee W, MVP earned 250 total points
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

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…
HOW TO: Upload an ISO image to a VMware datastore for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere Host Client, and checking its MD5 checksum signature is correct.  It's a good idea to compare checksums, because many installat…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

16 Experts available now in Live!

Get 1:1 Help Now