Announcement

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

  • How to access file information including file names, date modified, etc.

    Hello,

    I'm writing a do file for creating a text file (*.txt) to record the information of a list of files in a directory. (The files could be .dta, .ado, .mata, .mlib, etc.) By 'record', I mean not only printing the information in the text file, but also using the information for further editing.

    I know that Stata's built-in command dir can display file information, but it doesn't store the information in the r(), so I can't do further editing. On the contrary, the macro extended function dir does let me access file names, but it doesn't give me the information of date modified. I've thought about using Stata's command shell. Unfortunately, I know nothing about windows shell syntax. Therefore, I'm here for seeking help. Is there any Stata's command(s) serving my purpose?

    Thank you very much in advance.

  • #2
    Code:
    ! dir > output.txt
    will create in the current working directory an ASCII text file, output.txt, containing the relevant information. You can then use the file commands to manipulate this file. Another approach would to use log-files and process those.

    Best
    Daniel
    Last edited by daniel klein; 20 Apr 2017, 04:05.

    Comment


    • #3
      Klein, thank you very much. The commands dir, log, and file together solve my problem. Thanks.

      Comment

      Working...
      X