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


Click here to return to the 'Open a random file in the GUI via a bash script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Open a random file in the GUI via a bash script
Authored by: kejadlen on Nov 14, '05 07:40:54AM
In Ruby:
Dir.chdir "/Users/me/Documents/"
docs = Dir["*.{txt,rtf,doc}"]
exec "open", "-e", docs[rand(docs.size)]
Temp files are a slight security risk, and this seemed a little cleaner.

[ Reply to This | # ]
Open a random file in the GUI via a bash script
Authored by: avarame on Nov 14, '05 12:07:39PM

I laughed when I saw this post. Of COURSE there's an easier way to do it in Ruby!

Kudos to you, sir or ma'am!



[ Reply to This | # ]