MSFN Forum: save current DATE & TIME as TXT File from Batch - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

save current DATE & TIME as TXT File from Batch Rate Topic: -----

#1 User is offline   mehargags 

  • Junior
  • Pip
  • Group: Members
  • Posts: 63
  • Joined: 28-January 04

Posted 13 July 2006 - 11:14 PM

Hi Freinds,
I want to make a windows BATCH file that can save Current Date & time inside a TXT file & save the TXT file as somename.txt.......

I checked many sites but din't get a clue how to save current DATE & TIME AS a TXT File..


Can u pls do this small code for me?? Im aware of the date & time Variables in batch but dunno how to create a tXT file from them..


Dunno which is the right section for this but this one seemed the most feasible :rolleyes:
Thx


#2 User is offline   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,020
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 13 July 2006 - 11:34 PM

Try this the text file will be saved in the directory that the script ran from

Quote

@echo Off
Set T=%time%
set D=%Date%
echo %T% - %D% >> TimeDate.txt


#3 User is offline   jaws75 

  • Member
  • PipPip
  • Group: Members
  • Posts: 124
  • Joined: 22-April 06

Posted 13 July 2006 - 11:57 PM

The same only different

@ECHO OFF
FOR /F "TOKENS=1-3 DELIMS=." %%a IN ("%time%") DO SET hhmmss=%%a
>>date.txt echo %date%
>>date.txt echo %hhmmss%


#4 User is offline   Gee 

  • Member
  • PipPip
  • Group: Members
  • Posts: 275
  • Joined: 31-October 03

Posted 14 July 2006 - 11:36 PM

There are may ways to do this. You can even change your prompt and get a directory listing.

@echo off
prompt $t $d
dir > file.txt


Prompt will show time and date and the listing of the current directory. File will be saved in same directory.

#5 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 9,114
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 15 July 2006 - 03:22 AM

Please note that the > character (as in last post) will OVERWRITE the file, if existing before, whilst the >> characters will APPEND to it.

There is an even simpler method using a built-in, not widely known, feature of NOTEPAD:
http://support.micro...om/?kbid=260563

jaclaz

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy