Rename file with file creation date
Keywords: Rename fileYMDHMS create date
Code to Rename file with file creation date.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Debug(1)
path="C:\Temp\"
file="test.txt"
fullfile=strcat(path,file)
if fileexist(fullfile)==1
a=FileYMDHMS(fullfile)
;;;This will separate it into 3 separate parts; param1, param2, param3
Year=Itemextract(1, a, ":")
Month=ItemExtract(2, a, ":")
Day=ItemExtract(3, a, ":")
;;;Some days and months may only have one digit. To make sure they have two digits:
If StrLen(month) == 1 then month="0%month%"
If StrLen(day) == 1 then day= "0%day%"
;;;Get file extension of the file
ext = FileExtension(fullfile)
;;;You need to concantenate the parts together.
Datename=StrCat( path,month,day,year,".",ext)
message("NEWNAME",datename)
;;;Rename the file
Filerename(fullfile,datename)
message("FileRename","SUCESSFUL")
endif
message("FileRename","FINISHED")
Article ID: W13756
Filename: Rename file with file creation date.txt