batch script that tells me when was the last time a file has been accessed

前端 未结 3 863
执笔经年
执笔经年 2021-01-24 21:01

I have a list of sales orders in a folder. I want a batch script that can output into a txt file, when were all the files last accessed but not necessarily modified.

相关标签:
3条回答
  • 2021-01-24 21:14

    On partitions with NTFS file system there are 3 file dates: creation date, last modification date and last access date.

    The command

    dir "path to directory" /TA /OD
    

    lists all files of the directory according to last access date with last accessed file at bottom.

    dir "path to directory" /TA /O-D
    

    list the files in reverse order with last accessed file at top.

    It is of course possible to redirect the output into a file by appending >"Name of list file with path.log"

    But don't trust the last access time too much as it is really not reliable on when a file was last time opened for read only.

    For more parameters of command dir open a command prompt window and enter dir /?

    0 讨论(0)
  • 2021-01-24 21:18

    As others have said, Last Access Date is not reliable on NTFS. But if you wanted to extract it anyway, here is one way, but it will need a bit more parsing:

    wmic DataFile where "Name='C:\\Users\\Default\\NTUSER.DAT'" get LastAccessed /value
    
    0 讨论(0)
  • 2021-01-24 21:19

    Last Access has been turned off by default for many years.

    This command shows the setting of any computer you are interested in.

    fsutil behavior query disablelastaccess
    

    For using lastaccess - programs that don't open a file under user direction (eg search indexers, icon extractors like explorer, property sheets, etc) have to go back and restore last access to what it was before they opened it.

    0 讨论(0)
提交回复
热议问题