Search : in
By :

Batch file for one current date in text file

Last answer on Oct 19, 2009 1:47:35 pm BST AMI, on Jul 24, 2008 8:41:09 am BST 
 Report this message to moderators

Hello,
I need a batch file to get the current date and time of my computer and put it in a text file every time I run it.But I need the most current date&time to replace the previous within the same text file, so that my file can have only one record, even if I run it multiple times.
I found this code:
<codeecho %date% %time% >> log.txt></code>
But this one just adds the next date under the previous one.
Your help would be greatly appreciated. Thanks in advance!

Best answers for « Batch file for one current date in text file » in :
Batch file – Get Filenames & Timestamps Show Batch file – Get Filenames & Timestamps Issue Solution Note Issue Can anyone help me create a batch file that will display all the files, subfolders and files under subfolders of folder with both date created and date modified then...
What is a batch file? ShowWhat is a batch file? Creating a batch file Prerequisites Create file Windows comes with a version of DOS, which allows you,exploiting the features and the sequence of commands in a script. Batch file, is a simple text file (ascii)...
Batch Script - Move files to \%date%\%time%\ ShowBatch Script - Move files to \%date%\%time%\ Issue Solution Note Issue I have been trying to make a simple batch script to create database backups and move then into a folder named by date, and a sub folder by time. This is what I...
Automatic backup of a Database in SQL EXPRESS 2005 ShowAutomatic backup of a Database in SQL EXPRESS 2005 If you want to automate a backup of a database in SQL Server Express, there is a simple solution using a .bat. file. Create a new text file. This file should contain the following...

1

Ola Ljunggren, on Aug 22, 2008 7:33:09 am BST

Hi,

Remove one of the '>' and you have solved it.

It should look like this:
echo %date% %time% > log.txt

:) Ola

Reply to Ola Ljunggren

2

Mac, on Jan 8, 2009 10:58:06 am GMT
  • +3

Hi

how do i write a script to find system date in the following format YYYYMMDD and use it to create folder using the same date.

Reply to Mac

11

Sleez, on Apr 28, 2009 3:47:50 pm BST
  • +6

These are some simple string manipulations to get Date, Time, and DOW if you would rather not use a FOR

REM - Create Date and Time strings
set Today=%date:~10,4%%date:~4,2%%date:~7,2%
set Now=%time:~0,2%%time:~3,2%%time:~6,2%
set DOW=%date:~0,3%

Reply to Sleez

8

abdullah, on Mar 9, 2009 9:01:55 am GMT

Create one log.txt file on your c:\drive
say log.txt
and create one bat file ,open in edit mode and write the below line of code

echo the current date and tine is %time%%date%>>log.txt

Reply to abdullah

12

Maram, on May 5, 2009 6:15:07 pm BST

Hi,
I need program or procedure to extract the Gregorian date and the equevelent Hijri date from windows to the text file for 10 years .
waiting for your response .

Reply to Maram

3

MR. Skitzo, on Jan 12, 2009 9:06:51 am GMT

Here's your long awaited answer...

echo %time% %date%>text.txt

note: use only one ">" in the command line so it will erase the previous txt file and replace it with the text you want.

Reply to MR. Skitzo

7

rblanda, on Feb 21, 2009 1:12:54 pm GMT

I was wondering if you gurus can give me some direction...

I run a Specials Menu at a restaurant using powerpoint. There are two specials files (lunch.pps and dinner.pps)
When this system reboots, i want a batch file to determine which powerpoint file to open based on what time it is.

For instance, if it's anywhere between 11am and 3pm, open the lunch file. If its any other time, run the dinner.pps file. Make sense?

Does anyone know what the syntax is to do this?

Reply to rblanda

9

Brett, on Mar 25, 2009 2:45:36 pm GMT
  • +5

For /f "tokens=1-2 delims=: " %%a in ('time /T') do set hour=%%a
if %hour% gtr 15 goto xxx

The above will check the hour is e.g. 3pm

Reply to Brett

4

13F0cUs37 , on Jan 22, 2009 3:22:24 pm GMT

Where do i put the codes?

Reply to 13F0cUs37

5

Bond, on Jan 22, 2009 7:46:00 pm GMT
  • +6

Im currently running an ant script that will zip up a directory of errors for me. I want it to store the files but time stamp the files so that the date and time they were created are in the zipped file name is that possible?

Reply to Bond

6

Mach, on Feb 17, 2009 12:33:05 pm GMT

I want use find and replace opition on folders and directories.

Reply to Mach

10

temp, on Apr 1, 2009 9:50:53 am BST
  • +2

This works well... removes "/"

FOR %%A IN (%Date:/=%) DO SET Today=%%A
ren test.txt "test "%TODAY%.txt

Reply to temp

13

 Binooplal, on May 22, 2009 12:55:03 pm BST
  • +3

To Rename Any File With Date And Time Padded

set dd = %date% %Time%

Ren File_To_Rename.txt MyFile__%dd:~0,2%_%dd:~3,2%_%dd:~6,4%___%dd:~11,2%_%dd:~14,2­%.txt


Output
--------
MyFile__22_05_2009__6_20.txt

Reply to Binooplal