China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-25 06:35
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to read the modification time of a file View 3,818 Replies 8
Original Poster Posted 2006-10-13 21:35 ·  中国 上海 宝山区 电信
初级用户
★★
Credits 153
Posts 68
Joined 2006-10-12 22:25
19-year member
UID 65507
From 上海
Status Offline
I searched the forum and didn't find a post discussing this issue, so I'm posting to ask everyone for help:

How to read the modification time of a file, for example: D:\test.xls

How to obtain the modification time of this file, for example: June 13, 2006, 13:36:28

[ Last edited by uemuem on 2006-10-14 at 01:33 ]
Floor 2 Posted 2006-10-13 21:45 ·  中国 北京 联通
银牌会员
★★★
努力做坏人
Credits 1,185
Posts 438
Joined 2006-08-28 12:00
19-year member
UID 61449
From 北京
Status Offline
@echo off
echo %~t1 Saved as test.cmd

Running test.cmd d:\test.xls should allow you to see it
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
redtek +1 2006-10-13 21:58
我今后在论坛的目标就是做个超级坏人!!!
Floor 3 Posted 2006-10-13 21:54 ·  中国 上海 宝山区 电信
初级用户
★★
Credits 153
Posts 68
Joined 2006-10-12 22:25
19-year member
UID 65507
From 上海
Status Offline
Thanks, this works, but it's a bit cumbersome. Can you combine it into one BAT file and save the result to 1.txt? I just tried it and it didn't work properly.
Floor 4 Posted 2006-10-13 22:00 ·  中国 北京 联通
银牌会员
★★★
努力做坏人
Credits 1,185
Posts 438
Joined 2006-08-28 12:00
19-year member
UID 61449
From 北京
Status Offline
@echo off
call :dan D:\test.xls
start 1.txt
goto :eof

:dan
echo %~t1 >1.txt
goto :eof

[ Last edited by pip on 2006-10-14 at 02:45 ]
我今后在论坛的目标就是做个超级坏人!!!
Floor 5 Posted 2006-10-13 22:02 ·  中国 上海 宝山区 电信
初级用户
★★
Credits 153
Posts 68
Joined 2006-10-12 22:25
19-year member
UID 65507
From 上海
Status Offline
Really thank you, thank you PIP, I want to use him to judge whether the file has been modified, and then make a backup!
Floor 6 Posted 2006-10-13 22:12 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
To determine whether a file has been modified, one way is to judge by the modification time, and the other is to look at the archive attribute (you need to remove the archive attribute first before).
Floor 7 Posted 2006-10-13 22:41 ·  中国 上海 宝山区 电信
初级用户
★★
Credits 153
Posts 68
Joined 2006-10-12 22:25
19-year member
UID 65507
From 上海
Status Offline
The moderator's words are a bit advanced, and I don't quite understand.

Can you give an example?

Or give an automatic backup code for beginners to learn. I've just started and have too many things to learn.

For example: I want to judge whether D:\test.xls has been changed. If it has been changed, back it up to E:\test modification time.xls; if it hasn't been changed, do nothing...

[ Last edited by uemuem on 2006-10-13 at 22:47 ]
个人主页-找餐厅:http://www.canting.cc
Floor 8 Posted 2006-10-13 23:39 ·  中国 甘肃 平凉 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Figuring this out will solve your problem:
http://www.cn-dos.net/forum/viewthread.php?tid=22195&fpage=1
Floor 9 Posted 2006-10-14 01:04 ·  中国 四川 成都 移动
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
The most commonly used commands often contain the most powerful functions. Please see the relevant help information for dir:

DIR attributes]]
sortorder]] timefield]]
……
timefield C Creation time
A Last access time
W Last write time
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Forum Jump: