mardi 20 février 2018

Bash (MAC): How to get a random file name in a directory

I want to get and open a random file from a folder.

Let's say I have a group of files in: /Users/Me/Downloads/Stuff/

I want a command that return the filepath of a randomly chosen file in the Stuff folder.

aka.

randFile = /Users/Me/Downloads/Stuff/randVid.exe

then I want to open with

open -a "QuickTime Player" randFile

I understand how to open the file with the desired program but I am having trouble finding out the solution to getting a randomly chosen file since I am not too well versed in bash.

Thanks for your time!




Aucun commentaire:

Enregistrer un commentaire