Skip to content

Instantly share code, notes, and snippets.

@zhrkvl
Created September 7, 2015 20:02
Show Gist options
  • Select an option

  • Save zhrkvl/27b74600318b4d0d0ad1 to your computer and use it in GitHub Desktop.

Select an option

Save zhrkvl/27b74600318b4d0d0ad1 to your computer and use it in GitHub Desktop.
import sys
import os
import os.path
import random
from os.path import join
inDir = r'C:\kek'
if(input('Input dir is: {}\nIs it correct?(y/n):'.format(inDir)) == 'n'):
inDir = input('So, write input dir path:')
random.seed()
fl = open(join(inDir, 'log.txt'), 'w')
def f(curPath = inDir):
for f in os.listdir(curPath):
if(os.path.isfile( join(curPath, f) ) and f[-4:] == '.mp3'):
newfn = join(curPath, str(random.randint(0, 1024)) + ' ' + f)
os.rename(join(curPath, f), newfn)
# print('rename {}'.format(join(curPath, str(random.randint(0, 1024)) + ' ' + f)))
fl.write('{}\n'.format(newfn)
elif(os.path.isdir( join(curPath, f) )):
f( join(curPath, f) )
f()
fl.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment