Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

datetime stamp

Posted on 2004-10-19
2
Medium Priority
?
712 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 1000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Whoever said that “a picture is worth one thousand words” observed a fact that can dramatically affect your marketing success. Most people tend to learn visually, so many publishers commonly acknowledge the effectiveness of visual learning by using…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

715 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