From: James Bunton Date: Sun, 31 Jul 2016 04:58:36 +0000 (+1000) Subject: mythsymlink: generate a random filename if there is a conflict X-Git-Url: https://code.delx.au/mediapc-tools/commitdiff_plain/a6145d5bc896d9a2ad5ce723d24fb0934e715f6b mythsymlink: generate a random filename if there is a conflict --- diff --git a/mythsymlink b/mythsymlink index c744210..42a4f9b 100755 --- a/mythsymlink +++ b/mythsymlink @@ -1,6 +1,7 @@ #!/usr/bin/env python2 import os +import random import re import socket import sys @@ -77,6 +78,9 @@ for row in cursor: if not os.path.isfile(source): continue + if os.path.isfile(dest): + dest = os.path.splitext(dest)[0] + ' - unique' + str(random.randint(1000, 9999)) + extn + dirnames = dest.split("/")[:-1] for i in xrange(1, len(dirnames)+1): dirname = "/".join(dirnames[:i])