Some examples:
;;-----------------=={ File Last Modified }==-----------------;;
;; ;;
;; Returns the Last Modified property of a file in Julian ;;
;; time ;;
;;------------------------------------------------------------;;
;; Author: Lee McDonnell, 2010 ;;
;; ;;
;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
;;------------------------------------------------------------;;
;; Arguments: ;;
;; file - full filepath of file to query ;;
;;------------------------------------------------------------;;
;; Returns: Last Modified Date (Julian), else nil ;;
;;------------------------------------------------------------;;
(defun LM:FileLastModified ( file / fso fObj date )
(vl-load-com)
;; © Lee Mac 2010
(setq fso (vlax-create-object "Scripting.FileSystemObject"))
(cond ( (zerop (vlax-invoke fso 'FileExists file)))
( (setq fObj (vlax-invoke-method fso 'GetFile file)
date (+ 2415019 (vlax-get fObj 'DateLastModified)))))
(vlax-release-object fso)
date
)
;;--------------------=={ File Created }==--------------------;;
;; ;;
;; Returns the DateCreated property of a file in Julian ;;
;; time ;;
;;------------------------------------------------------------;;
;; Author: Lee McDonnell, 2010 ;;
;; ;;
;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
;;------------------------------------------------------------;;
;; Arguments: ;;
;; file - full filepath of file to query ;;
;;------------------------------------------------------------;;
;; Returns: Creation Date (Julian), else nil ;;
;;------------------------------------------------------------;;
(defun LM:FileCreated ( file / fso fObj date )
(vl-load-com)
;; © Lee Mac 2010
(setq fso (vlax-create-object "Scripting.FileSystemObject"))
(cond ( (zerop (vlax-invoke fso 'FileExists file)))
( (setq fObj (vlax-invoke-method fso 'GetFile file)
date (+ 2415019 (vlax-get fObj 'DateCreated)))))
(vlax-release-object fso)
date
)
;;--------------------=={ File Info }==-----------------------;;
;; ;;
;; Returns the Last Modified property of a file in Julian ;;
;; time ;;
;;------------------------------------------------------------;;
;; Author: Lee McDonnell, 2010 ;;
;; ;;
;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
;;------------------------------------------------------------;;
;; Arguments: ;;
;; file - full filepath of file to query ;;
;;------------------------------------------------------------;;
;; Returns: ;;
;; List of file information: ;;
;; <FileName> ~ name of file ;;
;; <DateCreated> ~ Julian date of file creation ;;
;; <DateLastAccessed> ~ Julian date of file last accessed ;;
;; <DateLastModified> ~ Julian date of file last modified ;;
;; <Size> ~ Size of file in bytes ;;
;;------------------------------------------------------------;;
(defun LM:FileInfo ( file / fso fObj info )
(vl-load-com)
;; © Lee Mac 2010
(setq fso (vlax-create-object "Scripting.FileSystemObject"))
(cond ( (zerop (vlax-invoke fso 'FileExists file)))
( (setq fObj (vlax-invoke-method fso 'GetFile file))
(setq info (mapcar '(lambda ( property functionn ) ((eval functionn) (vlax-get fObj property)))
'(Name DateCreated DateLastAccessed DateLastModified Size)
'((lambda ( x ) x )
(lambda ( x ) (+ x 2415019))
(lambda ( x ) (+ x 2415019))
(lambda ( x ) (+ x 2415019))
(lambda ( x ) x ))))))
(vlax-release-object fso)
info
)
(defun LM:FormatDate ( date format )
;; © Lee Mac 2010
(menucmd (strcat "m=$(edtime," date "," format ")"))
)
;; Test Function
(defun c:test ( / f i )
(vl-load-com)
(if (and (setq f (getfiled "Select File to Query" "" "" 16))
(setq i (LM:FileInfo f)))
(princ
(strcat
"\n-- Information for: " (car i)
(apply 'strcat
(mapcar 'strcat '("\nCreated: " "\nAccessed: " "\nModified: ")
(mapcar '(lambda ( x ) (LM:FormatDate (rtos x 2 15) "DD.MO.YYYY HH:MM:SS")) (cdr i))
)
)
"\nSize (KB): " (rtos (/ (last i) 1024.) 2 3)
)
)
)
(princ)
)
Another test function calling the above subs:
(defun c:GetCreatedTest ( / f )
(if (setq f (getfiled "Select File to Query" "" "" 16))
(print
(LM:FormatDate (rtos (LM:FileCreated f) 2 15) "DD.MO.YYYY HH:MM:SS")
)
)
(princ)
)