DATA Step, Macro, Functions and more

Getting create and modified dates from directory listing

Reply
Super Contributor
Posts: 398

Getting create and modified dates from directory listing

Hello,

 

I'm trying to get the create and modified dates from a directory listing using filename and pipe. 

 

filename dump pipe "dir ""&&folder&i..\&&filename&i..*.*"" /b " ;

This is the line that I'm doing to pull all the files that start with a specific file name.  This returnes all the file names, but no other information.  I know it has something to do with "/b" but I'm unable to find a good descripiton of the different modifiers. 

I'm guessing it will add the dates along with the name in one character field, correct?

Super Contributor
Posts: 394

Re: Getting create and modified dates from directory listing

Two ways to get help on the dir command:

  1. Start a Windows command window and enter dir /?.
  2. Google "dir command windows".
Super User
Posts: 6,963

Re: Getting create and modified dates from directory listing

Be aware that the "file creation timestamp" in Windows may be complete bogus, depending on your point of view.

Create a file called xxx.txt today.

One month from now, once again create a file called xxx.txt in the same directory (don't delete the original file before that).

Look at the creation timestamp (dir /tc) and be surprised ("File system tunneling").

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 7,413

Re: Getting create and modified dates from directory listing

@KurtBremser has really pulled the main issue here.  Don't rely on Windows dates/times for anything, there are numerous ways to fiddle those.  Why do you need this information?  If it is for audit purpose, then you would need to get your version control system date/times or other locked down system dates/times that you can't tamper with.  Otherwise the process is meaningless.  

If its just to find a specific set of files, then there is probably betters was of organising it to find this information.

 

 

/b = bare format by the way.

Super User
Posts: 10,538

Re: Getting create and modified dates from directory listing

In addition to all the good comments above, you could investigate the SAS external file functions Dopen DNUM Dread FOPTNUM FOPTNAME FINFO.

 

These functions are quite as system dependent as the DIR pipe. Not to mention that Microsoft changes options on things like the DIR command with different versions.

Super Contributor
Posts: 398

Re: Getting create and modified dates from directory listing

Thank you everyone.

The date on the sad file will be used to compare to the same set of files in our archive and production data.
We use the creation date to let us compare to make sure we have the latest file and if not we know we have to do a release.
Super User
Posts: 6,963

Re: Getting create and modified dates from directory listing

The creation date will not give you the latest file. For that, you need the modification timestamp.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 398

Re: Getting create and modified dates from directory listing

Thank you Kurt,

 

That is what I need.  I need the modification timestamp from a directory listing.

 

Thanks

Ask a Question
Discussion stats
  • 7 replies
  • 343 views
  • 0 likes
  • 5 in conversation