Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 20-04-2009
Member
 
Join Date: Apr 2009
Posts: 55
Date and Time format in a BATCH File

Hello,

Can we set the Date and Time for certain Batch files even though that Batch files need not to be forwarded but want to show that batch files should be updated for each time.when we login to the system.

This processing would keep backup of all the files and folders that we have selected for Batch Processing.

Thanks
Reply With Quote
  #2  
Old 20-04-2009
Member
 
Join Date: Jan 2009
Posts: 99
Re: Date and Time format in a BATCH File

IDATE.BAT:
This batch file checks the date format setting (mm/dd/yy, dd/mm/yy or yy/mm/dd):

@ECHO OFF
:: For REG.EXE 3.0 (Windows XP) and later versions
FOR /F "tokens=3" %%A IN ('REG QUERY "HKEY_CURRENT_USER\Control Panel\International" /v iDate 2?>NUL') DO SET iDate=%%A
:: For earlier REG.EXE versions
FOR /F "tokens=3" %%A IN ('REG QUERY "HKEY_CURRENT_USER\Control Panel\International\iDate" 2?>NUL') DO SET iDate=%%A
ECHO HKEY_CURRENT_USER\Control Panel\International\iDate=%iDate%
Reply With Quote
  #3  
Old 20-04-2009
Member
 
Join Date: Mar 2008
Posts: 258
Re: Date and Time format in a BATCH File

Just copy and paste the text in quotes to a text file. Then rename file test.bat and run from command line to see (echo is on by default).

This can be used in a very powerful way, the FOR command can be reused and changed to query to see if a file exists and then if so create the folder, etc.

for now, lets start basic?

Code:
echo on
      @REM Seamonkey?s quick date batch (MMDDYYYY format)
      @REM Setups %date variable
      @REM First parses month, day, and year into mm , dd, yyyy formats and then combines to be MMDDYYYY

      FOR /F ?TOKENS=1* DELIMS= ? %%A IN (?DATE/T?) DO SET CDATE=%%B
      FOR /F ?TOKENS=1,2 eol=/ DELIMS=/ ? %%A IN (?DATE/T?) DO SET mm=%%B
      FOR /F ?TOKENS=1,2 DELIMS=/ eol=/? %%A IN (?echo %CDATE%?) DO SET dd=%%B
      FOR /F ?TOKENS=2,3 DELIMS=/ ? %%A IN (?echo %CDATE%?) DO SET yyyy=%%B
      SET date=%mm%%dd%%yyyy%
this does nothing but setup the %date variable to be todays date in MMDDYYYY format so it can be called later in the script, etc..
Reply With Quote
  #4  
Old 20-04-2009
Member
 
Join Date: Oct 2008
Posts: 167
Re: Date and Time format in a BATCH File

The only way I know that I know that what you are trying to do might be possible is using the for command and the ~t expanding parameter.

Quote:
for %r in (*.*) DO echo %r "created on" %~tr
That produces:
Quote:
C:\>echo BOOTSECT.BAK "created on" 2009/02/17 11:59 PM
BOOTSECT.BAK "created on" 2009/02/17 11:59 PM

C:\>echo config.sys "created on" 2006/09/18 11:43 PM
config.sys "created on" 2006/09/18 11:43 PM
I think a more likely scenario would involve using windows scripting host, or powershell, but you did not mention that those are options for you, so I am assuming that there is a good reason, for not being able to use those technologies.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Date and Time format in a BATCH File"
Thread Thread Starter Forum Replies Last Post
Formatting Modified Date Variable in Batch File erock24 Software Development 1 21-10-2011 12:39 PM
How to run batch file at specific time Campbel Software Development 4 27-03-2010 07:32 PM
Format Date and Time Script in ASP Beter 2 Burn Out Software Development 4 10-02-2010 02:22 AM
Batch file to create directory with a date in Windows 2003 Aadimoolan Window 2000 Help 2 16-11-2007 02:55 AM


All times are GMT +5.5. The time now is 12:28 PM.