DOS Dir - listing of full path and timestamp | Unix Linux Forums | Windows & DOS: Issues & Discussions

  Go Back    


Windows & DOS: Issues & Discussions All Windows and DOS questions should go here as well. Discuss UNIX to Windows (Desktop or Server) here!

DOS Dir - listing of full path and timestamp

Windows & DOS: Issues & Discussions


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-09-2010
GM_AIX GM_AIX is offline
Registered User
 
Join Date: Aug 2010
Last Activity: 3 December 2010, 5:51 AM EST
Posts: 5
Thanks: 3
Thanked 0 Times in 0 Posts
DOS Dir - listing of full path and timestamp

Hi,

(Apologies, I'm sure I'm not the first person to raise this question but so far in my searches haven't found a good answer).

I would like to output a listing per line of filename (including full path) and 'last updated' timestamp. e.g:

Code:
Z:\dir1\file1.txt   01/02/2010 10:43
z:\dir1\file2.txt   12/04/2010  09:30
z:\dir1\dir2\file3.txt   26/05/2010  13:01
z:\dir1\dir2\file4.txt   26/05/2010  13:02

I expect 1000+ files to be reported in my real scenario. The ultimate aim is to export to Excel and sort by date.

I had hoped to use the DOS DIR command.

Thanks in advance for any help.

---------- Post updated at 12:37 PM ---------- Previous update was at 06:10 AM ----------

Come on folk - it can't be that hard...
Sponsored Links
    #2  
Old 09-09-2010
Lakris Lakris is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 13 June 2012, 2:08 PM EDT
Location: Stockholm
Posts: 317
Thanks: 0
Thanked 7 Times in 7 Posts
Hi, what have You tried Yourself?

I'm afraid You can't do that with the dir command alone. Do You mean DOS or NT (command.exe or cmd.exe)?
But if You combine it with the "FOR /F" You can extract the needed columns and order them as You want. Have a look at SS64.com Command line reference, an excellent site for explaining some of the most common scripting languages.

I'm not sure about the full path, maybe You would have to combine the command by using dir /s to get the directories, or perhaps tree.
I'm sure it's not THAT hard to find a command to create that list.

/Lakris
The Following User Says Thank You to Lakris For This Useful Post:
GM_AIX (09-10-2010)
Sponsored Links
    #3  
Old 09-10-2010
GM_AIX GM_AIX is offline
Registered User
 
Join Date: Aug 2010
Last Activity: 3 December 2010, 5:51 AM EST
Posts: 5
Thanks: 3
Thanked 0 Times in 0 Posts
Lakris,

Thank you - it is helpful just to have had it confirmed that I haven't missed a DIR switch.
It just feels frustrating that output displayed through the GUI Windows Search program can't be output to file and can't be directly replicated through DIR (I'm using CMD.exe by the way).
I'm sure that lots of people have had the same requirement but my initial Google searches didn't find anything ideal so I was hoping that someone here would have a quick answer. I'll go back to searching or work something out for myself.

GM_AIX

---------- Post updated at 04:44 AM ---------- Previous update was at 04:43 AM ----------

Oh, one extra point...

In my particular case, the directory structure is in a Clearcase stream, so if anyone happened to know a ClearTool solution, that would be a viable alternative on this occasion.
    #4  
Old 09-10-2010
Lakris Lakris is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 13 June 2012, 2:08 PM EDT
Location: Stockholm
Posts: 317
Thanks: 0
Thanked 7 Times in 7 Posts
No problems!
I often get frustrated about the shortcomings of "DOS". When I have a complicated script problem it often results in tweaks and workarounds and temporary files, fooling the shell with any number of %%% and """" (where nobody actually knows why it works, it just does, sometimes... also depending if it's in a bat/cmd-file or on an interactive command line) using dozens of programs, that so easily could have been solved with bash alone, possibly with a helper such as sort/grep/find/cut or whatever.

Good Luck!
/L

PS Have a look at the "FOR /R" construct. "http://ss64.com/nt/for_r.html" Can that help?
Sponsored Links
    #5  
Old 09-11-2010
niterobin's Avatar
niterobin niterobin is offline
Registered User
 
Join Date: Oct 2006
Last Activity: 4 December 2013, 4:42 PM EST
Location: Stevenage, UK.
Posts: 15
Thanks: 16
Thanked 0 Times in 0 Posts
DIR /O:A will sort the list by last access time with the earliest time first. I presume you could then sort the files by name if rerquired after exporting them to Excel.

And DIR /? will give you all the options.
Sponsored Links
    #6  
Old 09-13-2010
methyl methyl is offline Forum Advisor  
Advisor
 
Join Date: Mar 2008
Last Activity: 25 November 2014, 5:09 PM EST
Posts: 6,396
Thanks: 287
Thanked 673 Times in 642 Posts
You don't mention Windows or Excel versions.

Assuming XP.
This must be done in a Batch File (.bat).
The first script is your exact requirement. The second script puts the timestamp in front of the filename which is more readable.

Code:
@echo off
REM list files with timestamp
REM Filename first then timestamp
for /R %%I in (*.*) do @echo %%~dpnxI %%~tI

@echo off
REM list files with timestamp
REM Timestamp first then name
for /R %%I in (*.*) do @echo %%~tI %%~dpnxI

Just for interest, there are techniques available from Excel if you don't mind a bit of VB programming. For example (but do check your Excel and Windows version and re-search the KB).

XL: How to Put Folder Contents into a Worksheet

Last edited by methyl; 09-13-2010 at 01:50 PM.. Reason: typo
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Just listing size, timestamp & name of files in a directory Jazmania Shell Programming and Scripting 4 01-25-2010 02:21 PM
Listing files with full path r_sethu UNIX for Dummies Questions & Answers 5 06-15-2009 03:56 AM
getting full path from relative path polypus Shell Programming and Scripting 4 03-25-2007 01:08 PM
Full Directory Listing... B14speedfreak UNIX for Dummies Questions & Answers 5 05-11-2006 09:06 AM
Timestamp in directory listing vijashok UNIX for Dummies Questions & Answers 2 10-06-2005 11:03 AM



All times are GMT -4. The time now is 02:34 AM.