hhasee 发表于 2009-4-27 17:40:18

如何创建一个以当天日期时间命名的文件?

本帖最后由 hhasee 于 2009-4-29 13:31 编辑

因为要过段时间就要重新备份一下文件,因而想用系统的日期时间为名对文件进行命名,现在知文件夹可,但不知文件是否可以?请各位大侠赐招啊!

wongfung 发表于 2009-4-27 18:45:36

#Include <File.au3>

$file = FileOpenDialog("Open", @WorkingDir, "All Files(*.*)" , 1 )
FileMove($file, $file & "_" & @year & "_" & @MON & "_" & @MDAY, 1)

這個是在檔案後加: _年_月_日

p.s.在au3改名要用FileMove來改
p.s.2 其他時間宏相關:
@SEC
Seconds value of clock.Range is 00 to 59
@MIN
Minutes value of clock.Range is 00 to 59
@HOUR
Hours value of clock in 24-hour format.Range is 00 to 23
@MDAY
Current day of month.Range is 01 to 31
@MON
Current month.Range is 01 to 12
@YEAR
Current four-digit year
@WDAY
Numeric day of week.Range is 1 to 7 which corresponds to Sunday through Saturday.
@YDAY
Current day of year.Range is 1 to 366 (or 365 if not a leap year)

hhasee 发表于 2009-4-28 09:47:30

问题已解决了,不过FileMove为重表更改文件名,不是重新建立文件哦!

howie530_8 发表于 2010-6-25 10:22:58

回复 1# hhasee #Include <File.au3>
;打开当前的工作目录
$file = FileOpenDialog("Open", @WorkingDir, "All Files(*.*)" , 1 )
FileCopy($file, $file & "_" & @year & "_" & @MON & "_" & @MDAY, 1)
FileDelete($file)这样是否可以达到你的效果、呵呵
页: [1]
查看完整版本: 如何创建一个以当天日期时间命名的文件?