Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Create a directory list in CSV format' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create a directory list in CSV format
Authored by: jaysoffian on Aug 30, '06 09:37:36AM
And here's a version that doesn't require parsing the output of 'ls -l'

ls | perl -ne 'chomp;@s=stat;printf qq|"%s","%s","%s"\n|, $_, $s[7], scalar localtime $s[9]'
I'm sure someone will followup with the ruby version shortly. :-) j.

[ Reply to This | # ]
Ruby version
Authored by: regeya on Aug 30, '06 12:07:33PM
With no 'ls' at all:

ruby -e 'Dir.foreach(".") {|f| x=File.stat(f) ; puts "#{f}, #{x.ctime}, #{x.size}"'} It could probably be shorter/prettier, and the output isn't exactly like the original, but it'll do. :-D

[ Reply to This | # ]

Another Ruby, this time with ls
Authored by: regeya on Aug 30, '06 01:06:45PM
ls | ruby -lne 'x = File.stat($_); puts "#{$_}, #{x.ctime}, #{x.size}"'

I suppose that one's cleaner than the other, but I still like the other better 'coz it's all Ruby. I'm weird that way. :-}

[ Reply to This | # ]

Another Ruby, this time with ls
Authored by: peragrin on Aug 31, '06 04:00:00AM

oddly enough this one fails with a folder with a custom icon.

where as the all ruby one parses it but leaves the line blank.

either way a quick modification a simple shell script and a way to create an index file for a directory is nice and easy.

---
I thought once I was found but it was only a dream



[ Reply to This | # ]