
import os
import subprocess
import sys
import uuid

if __name__ == '__main__':
    dir_name = sys.argv[1]

    for file_name in os.listdir(dir_name):
        rand_name = uuid.uuid4().hex
        src = os.path.join(dir_name, file_name)
        subprocess.check_call(['eyeD3', '--artist', rand_name, '--album', rand_name, src])

        os.rename(src, os.path.join(dir_name, '{} {}'.format(rand_name, file_name)))



import os
import subprocess
import sys
import uuid

if __name__ == '__main__':
    dir_name = sys.argv[1]

    for root, dirs, files in os.walk(dir_name):
        for file_name in files:
            rand_name = uuid.uuid4().hex
            src = os.path.join(root, file_name)
            if src.endswith('.mp3'):
                subprocess.check_call(['eyeD3', '--artist', rand_name, '--album', rand_name, src])

            os.rename(src, os.path.join(root, '{} {}'.format(rand_name, file_name)))


Generalize randomize script to work recursively and on more than just music
Generalize randomize script to work recursively and on more than just music

  
  import os
  import subprocess
  import sys
  import uuid
  
  if __name__ == '__main__':
      dir_name = sys.argv[1]
  
-     for file_name in os.listdir(dir_name):
+     for root, dirs, files in os.walk(dir_name):
+         for file_name in files:
-         rand_name = uuid.uuid4().hex
+             rand_name = uuid.uuid4().hex
-         src = os.path.join(dir_name, file_name)
+             src = os.path.join(root, file_name)
+             if src.endswith('.mp3'):
-         subprocess.check_call(['eyeD3', '--artist', rand_name, '--album', rand_name, src])
+                 subprocess.check_call(['eyeD3', '--artist', rand_name, '--album', rand_name, src])
  
-         os.rename(src, os.path.join(dir_name, '{} {}'.format(rand_name, file_name)))
+             os.rename(src, os.path.join(root, '{} {}'.format(rand_name, file_name)))
  
  
Generalize randomize script to work recursively and on more than just music
## Code Before:

import os
import subprocess
import sys
import uuid

if __name__ == '__main__':
    dir_name = sys.argv[1]

    for file_name in os.listdir(dir_name):
        rand_name = uuid.uuid4().hex
        src = os.path.join(dir_name, file_name)
        subprocess.check_call(['eyeD3', '--artist', rand_name, '--album', rand_name, src])

        os.rename(src, os.path.join(dir_name, '{} {}'.format(rand_name, file_name)))


## Instruction:
Generalize randomize script to work recursively and on more than just music
## Code After:

import os
import subprocess
import sys
import uuid

if __name__ == '__main__':
    dir_name = sys.argv[1]

    for root, dirs, files in os.walk(dir_name):
        for file_name in files:
            rand_name = uuid.uuid4().hex
            src = os.path.join(root, file_name)
            if src.endswith('.mp3'):
                subprocess.check_call(['eyeD3', '--artist', rand_name, '--album', rand_name, src])

            os.rename(src, os.path.join(root, '{} {}'.format(rand_name, file_name)))

