From 17f7ddbe7d6b37982cf03c10330f66cff9b355cc Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Sun, 13 Feb 2011 22:37:04 -0800 Subject: [PATCH] Add pickrand.py Signed-off-by: Colin McCabe --- pickrand.py | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) create mode 100755 pickrand.py diff --git a/pickrand.py b/pickrand.py new file mode 100755 index 0000000..8253e74 --- /dev/null +++ b/pickrand.py @@ -0,0 +1,17 @@ +#!/usr/bin/python + +import os +import random +import sys + +allfiles = [] + +for root, dirs, files in os.walk(".", followlinks=True): + for f in files: + allfiles.append(os.path.join(root, f)) +if (len(allfiles) == 0): + sys.exit(1) +random.seed(None) +r = random.randint(0,len(allfiles)) +print(allfiles[r]) +sys.exit(0) -- 1.6.6.rc1.39.g9a42