Skip to content

Instantly share code, notes, and snippets.

@dpastoor
Last active August 29, 2015 14:25
Show Gist options
  • Select an option

  • Save dpastoor/fc1092b8437cbda1ede6 to your computer and use it in GitHub Desktop.

Select an option

Save dpastoor/fc1092b8437cbda1ede6 to your computer and use it in GitHub Desktop.
compare files between folders python
*******************
import os
file_list1 = []
file_list2 = []
for top, dirs, files in os.walk('./'):
for nm in files:
file_list1.append(nm)
for top, dirs, files in os.walk('/Users/<user>/Music/iTunes/iTunes Media/Music/'):
for nm in files:
file_list2.append(nm)
songs1 = [file for file in file_list1 if file.endswith( ('.mp3','.m4a', '.m4p') ) ]
songs2 = [file for file in file_list2 if file.endswith( ('.mp3','.m4a', '.m4p') ) ]
set1 = set(songs1).difference(songs2)
set2 = set(songs2).difference(songs1)
print "files only in itunes media:"
print set2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment