Skip to content

Instantly share code, notes, and snippets.

@zhrkvl
Created September 7, 2015 19:42
Show Gist options
  • Select an option

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

Select an option

Save zhrkvl/e97a79124659604a9a86 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()
def f(curPath = inDir):
for f in os.listdir(curPath):
if(os.path.isfile( join(curPath, f) ) and f[-4:] == '.mp3'):
# os.rename(join(curPath, f), join(curPath, str(random(0, 1024)) + ' ' + f))
print('rename {}'.format(join(curPath, f), join(curPath, str(random.random(0, 1024)) + f)))
elif(os.path.isdir( join(curPath, f) )):
f( join(curPath, f) )
f()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment