Skip to content

Instantly share code, notes, and snippets.

@vinu76jsr
Created January 24, 2014 09:30
Show Gist options
  • Save vinu76jsr/8594481 to your computer and use it in GitHub Desktop.
Save vinu76jsr/8594481 to your computer and use it in GitHub Desktop.
A Python script to move mp3 files from one directory to a flat structure in another directory, Uses path.py module
"""
A Python script to move mp3 files from one directory to a
flat structure in another directory
Uses path.py module
"""
import os
from path import path
DIRECTORY = '/Users/vaibhav/Desktop/msc' # music source Directory
COPY_DIRECTORY = '/Users/vaibhav/Desktop/msc_copy' # Destination directory
d = path(DIRECTORY)
copy_directory = path(COPY_DIRECTORY)
def transfer():
print "Copying Files from %s to %s" % (d, copy_directory)
file_count = 0
for i in d.walk():
if i.isfile() and i.endswith('mp3'):
file_count += 1
print "Copying %s" % i
# i.copy(copy_directory)
print 'Transferred %s files' % file_count
if __name__ == "__main__":
transfer()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment