Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Obtain last modified date of files with a recursive search of network

    Hi all,

    Is anyone aware of a method I could use in Stata where I can search a network and return filenames and date last modified/opened? Some files will be buried deep within several subdirectories so I'll need to return the full filepath. I've used -filelist- from ssc in the past to do something similar which allows for a pattern search of files and returns the list to a dta file. I think this has been updated to return file size now as well.

    Thanks
    Tim

  • #2
    I don't know if this will work on your network, but you might be able to use Microsoft's Powershell:

    Code:
    . winexec  powershell Get-ChildItem -Path C:\Users\scott\Desktop\rf\  -Recurse |Export-csv folderlist.csv -notypeinf
    > ormation
    
    . import delimited "C:\Users\scott\Desktop\rf\folderlist.csv",clear
    (encoding automatically selected: ISO-8859-1)
    (23 vars, 11 obs)
    
    . l root parent fullname lastwritetime
    
         +-----------------------------------------------------------------------------------------+
         | root   parent                                          fullname           lastwritetime |
         |-----------------------------------------------------------------------------------------|
      1. |  C:\       rf                    C:\Users\scott\Desktop\rf\Test     8/2/2022 6:50:41 AM |
      2. |                        C:\Users\scott\Desktop\rf\folderlist.csv     8/2/2022 7:08:38 AM |
      3. |                             C:\Users\scott\Desktop\rf\Graph.png    8/1/2022 11:51:28 AM |
      4. |                 C:\Users\scott\Desktop\rf\rainfall threshold.do     8/2/2022 4:18:24 AM |
      5. |                         C:\Users\scott\Desktop\rf\rainfall1.dta    7/26/2022 2:23:31 PM |
         |-----------------------------------------------------------------------------------------|
      6. |                         C:\Users\scott\Desktop\rf\rainfall2.dta    7/26/2022 2:23:31 PM |
      7. |                                C:\Users\scott\Desktop\rf\rf.zip    7/26/2022 2:23:14 PM |
      8. |                               C:\Users\scott\Desktop\rf\rf1.csv    7/26/2022 5:42:00 PM |
      9. |                                C:\Users\scott\Desktop\rf\rf1.do    7/26/2022 5:42:00 PM |
     10. |                     C:\Users\scott\Desktop\rf\Test\rainfall.csv   7/25/2022 12:22:51 PM |
         |-----------------------------------------------------------------------------------------|
     11. |                      C:\Users\scott\Desktop\rf\Test\rainfall.do   7/25/2022 12:22:51 PM |
         +-----------------------------------------------------------------------------------------+
    See: http://docs.microsoft.com/en-us/powe...powershell-7.2

    Comment


    • #3
      Thanks Scott Merryman Powershell would have been my backup if no joy with Stata! Thanks for the code as well! I had written something in R but R didnt like the long names of the directory and I didnt figure how to solve it but hopefully your suggestion will work!

      Comment


      • #4
        For a solution that doesn’t require generating an additional file and parsing it see: https://github.com/wbuchanan/StataFileSystem

        Comment

        Working...
        X