Script Time Question  Leading 0

Posted on 2006-05-23
Last Modified: 2011-10-03

SET t1=%TIME:~0,2%
SET t2=%TIME:~3,2%
SET t3=%TIME:~6,4%
SET g1=%DATE:~4,2%
SET g2=%DATE:~7,2%
SET g3=%DATE:~10,4%

I use the above to get the time into chunks.

and them in a file.

move  myFile.txt    myFile-%g1%_%g2%_%g3%-%t1%_%t2%_%t3%.txt

It works fine as long as there is a 2 digit hour such as 10 11 or 12

If it is 7AM  how can I get the hour above to have a leading 0?   such as 07  instead of just 7

T1 above is what holds the hour.


Question by:rjohnsonjr
    LVL 9

    Accepted Solution


    If I guess well, it seems that you want to add date and time to your filename. I've tried to deal with that problem and finally gave up, because there is an excellent piece of software doing that for you :

    LVL 6

    Author Comment

    Thanks man,  This is an awesome utility

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    I guess it is not common knowledge to most Wintel engineers/administrators: If you have an SNMP-based monitoring system in your environment (and it's common to have SNMP or Syslog) it's reasonably easy to enable monitoring of the Windows Event logs,…
    ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    759 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

    14 Experts available now in Live!

    Get 1:1 Help Now