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-08-08 11:17
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How to change the creation time of a file View 2,153 Replies 11
Original Poster Posted 2008-05-05 22:39 ·  中国 广东 电信
新手上路
Credits 12
Posts 5
Joined 2006-07-08 22:25
20-year member
UID 58255
Status Offline
I want to create a file, but I want the creation time displayed not to be the current day. I don't know how to achieve it with a batch file. Please advise.
Floor 2 Posted 2008-05-05 23:09 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
```
@echo off
echo 04-05-2008|date
type nul>test.txt
echo 05-05-2008|date
```
Floor 3 Posted 2008-05-05 23:59 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
```
@echo off
echo 2008-04-05|date
type nul>test.txt
echo 2008-05-05|date
[ Last edited by zw19750516 on 2008-5-6 at 12:00 AM ]
```
批处理之家新域名:www.bathome.net
Floor 4 Posted 2008-05-06 21:58 ·  中国 广东 电信
新手上路
Credits 12
Posts 5
Joined 2006-07-08 22:25
20-year member
UID 58255
Status Offline
Thank you two, but it seems that this has changed the system time. Can it be done without changing the system time?
Floor 5 Posted 2008-05-06 22:09 ·  中国 广东 电信
新手上路
Credits 12
Posts 5
Joined 2006-07-08 22:25
20-year member
UID 58255
Status Offline
According to the ideas of the two, I also thought about changing the system time, but it's too troublesome because the current date is always being changed
@echo off
date 2008-04-05
type nul>test.txt
date 2008-05-05
Floor 6 Posted 2008-05-06 22:15 ·  中国 广西 玉林 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
```@echo off
set date_=%date:~0,10%
date 2008-04-05
type nul>test.txt
date %date_%
```
Floor 7 Posted 2008-05-06 23:22 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Originally posted by zw19750516 at 2008-5-5 11:59 PM:

@echo off
echo 2008-04-05|date
type nul>test.txt
echo 2008-05-05|date


[ Last edited by zw19750516 on 2008-5-6 at 12:00 AM ]

Different operating systems have different date formats. Yours is year-month-day, and mine is month-day-year. You can first determine the date format through the registry.
Floor 8 Posted 2008-05-07 03:51 ·  中国 广西 南宁 电信
中级用户
★★
丶杏灬丶
Credits 280
Posts 105
Joined 2008-05-06 03:37
18-year member
UID 117858
Gender Male
From 广西
Status Offline
A bit classic~~It's like cursing in a roundabout way^_^(for example)
Floor 9 Posted 2008-05-07 08:22 ·  中国 江苏 扬州 电信
高级用户
★★★
Credits 620
Posts 329
Joined 2007-12-05 15:34
18-year member
UID 104754
Gender Male
Status Offline
This is too difficult. Find a tool to modify file attributes. Can batch change...
Floor 10 Posted 2008-05-07 16:47 ·  中国 上海 联通
初级用户
★★
Credits 153
Posts 68
Joined 2006-10-12 22:25
19-year member
UID 65507
From 上海
Status Offline
Originally posted by HAT at 2008-5-5 23:09:
@echo off
echo 04-05-2008|date
type nul>test.txt
echo 05-05-2008|date

It doesn't work on 5-6, haha...
个人主页-找餐厅:http://www.canting.cc
Floor 11 Posted 2008-05-07 23:09 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Originally posted by uemuem at 2008-5-7 04:47 PM:

5-6 can't be used, haha...

When the month or day is a single digit, it needs to be padded with 0 to make it two digits. I don't know what you mean by 5-6
Floor 12 Posted 2008-05-08 00:07 ·  中国 山东 淄博 联通
银牌会员
★★★
Credits 1,604
Posts 646
Joined 2008-04-13 23:39
18-year member
UID 115804
Gender Male
Status Offline
The post on floor 11 reminds me of the Y2K bug - -|||
Forum Jump: