Windows Legacy OS forum

General discussion

Time stamp, add date stamp at the end of the file

by 10finch46 / January 1, 2009 12:46 PM PST

Hello, I want to copy or create one text file with a time stamp to check that my WSFTP upload scheduler is working properly.The syntax I have tried is;

Xcopy C:\Webs\Z_UpFtp.txt C:\Webs\zProducts_%date:~4,2%-%date:~7,2%-%date:~10%.txt

Xcopy Q:\Webs\Z_UpFtp.txt C:\Webs\zProducts_dd-mm-yyyy.txt

Xcopy Q:\Webs\*.txt C:\Webs\zProducts_dd-mm-yyyy.txt

ren Q:\Webs\Z_UpFtp.txt Z_UpFtp%timestamp%.txt

Any suggestions on the proper syntax will be apprciated

Discussion is locked
You are posting a reply to: Time stamp, add date stamp at the end of the file
The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our CNET Forums policies for details. All submitted content is subject to our Terms of Use.
Track this discussion and email me when there are updates

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

You are reporting the following post: Time stamp, add date stamp at the end of the file
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Collapse -
Re: add data to end of file.
by Kees Bakker / January 1, 2009 6:02 PM PST

The easiest way to add the contents of file A to file B:

type A>>B

The way to get time and date into A first:
with E being a file consisting only of a carriage return.

Combined this gives another way to add time and date to B:


The things you must know to understand this:
1. concatenate files using copy with + sign
2. output redirection using > and >>
3. input redirection using <


Collapse -
We have tried writing a new batch file
by 10finch46 / January 2, 2009 10:26 AM PST

Thank you for your suggestion, but the syntax I have used below does not work, could you please rewrite the correct batch file for us?

type A.txt>>B.txt

Collapse -
Re: batchfile
by Kees Bakker / January 3, 2009 12:18 AM PST

Just keep trying from the command prompt until you finally work it out. Then type the correct commands in a batch file.

I assume that E is one-line file you made like this:
- start Notepad
- File>New
- Pressing enter-key
- File>Save as e
- File>Exit
- use My Computer or Windows Explorer to rename e.txt to E without extension.

Then what your commands do is:
1. Append A.txt to B.txt
2. Open file c:\webs\kees.txt in Notepad
3. Append a line with the current date to file A.txt
4. Append a line with the current time to file A.txt
If E, however, is anything else than the above mentioned 2-byte file (it contains a carriage return and a linefeed) step 3 and 4 might not work as intended.


Collapse -
by Kees Bakker / January 3, 2009 2:37 AM PST
In reply to: Re: batchfile

Point 3 should be:
3. Replace the contents of file A with a line containing the current date.

So the end result of your 4 commands is:
a. The (old) contents of file A.txt is appended to file B.txt
b. The file c:\web\kees.txt is opened in Notepad
c. File A.txt is replaced by a file containing current date (line 1) and current time (line 2).

I wonder if that is what you want, even if it works.


Collapse -
Time stamp works, but
by 10finch46 / January 3, 2009 1:25 PM PST
In reply to: Correction.

Thank you for your suggestion and I now have the date in the new file.

We would like to reproduce this same type of date file in 36 folders and this works if we keep pressing [ F ] for file.

I have added at the end of the line [ space/f ] in both upper and lower cases on our XP machine without success. Do you have a suggestion on how to pragmatically update all the files so that we can have this batch file run with our scheduler for FTP uploading.


Collapse -
(NT) Not clear to me what you do and what you want.
by Kees Bakker / January 3, 2009 6:53 PM PST
In reply to: Time stamp works, but
Collapse -
no /f required
by 10finch46 / January 4, 2009 1:24 AM PST

We would like to like to have this batch file
Xcopy C:\Webs\zUpFtp.txt C:\Webs\UpFtp_Products\zProducts_%date:~4,2%-%date:~7,2%-%date:~10%.txt
which will be run by the windows scheduler, create the new date stamped record for each of the 36 folders, without a manual entry of [ f ] as required below

C:\Batch_Files>Xcopy C:\Webs\zUpFtp.txt C:\Webs\UpFtp_Products\zProducts_dd-mm-y
Does C:\Webs\UpFtp_Products\zProducts_dd-mm-yyyy.txt specify a file name
or directory name on the target
(F = file, D = directory)?


Collapse -
(NT) Use copy instead of xcopy.
by Kees Bakker / January 4, 2009 1:38 AM PST
In reply to: no /f required
Collapse -
Or use input redirection from a file containing the F.
by Kees Bakker / January 4, 2009 1:39 AM PST

Two good possibilities, it seems.


Popular Forums
Computer Newbies 10,686 discussions
Computer Help 54,365 discussions
Laptops 21,181 discussions
Networking & Wireless 16,313 discussions
Phones 17,137 discussions
Security 31,287 discussions
TVs & Home Theaters 22,101 discussions
Windows 7 8,164 discussions
Windows 10 2,657 discussions


Turn up the volume with our Apple Byte sweeps!

Two lucky winners will take home the coveted smart speaker that lets Siri help you around your connected house. This sweepstake ends Feb. 25, 2018.