Skip to content

Instantly share code, notes, and snippets.

@arto-heino
Created June 27, 2019 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arto-heino/de2691ae21e113ccfc08aa96e440ed99 to your computer and use it in GitHub Desktop.
Save arto-heino/de2691ae21e113ccfc08aa96e440ed99 to your computer and use it in GitHub Desktop.
list = os.listdir(path)
# Files are now named ssn_filename_uniqueid.filetype
# Set files to list ['filename','unique_id','file_type']
def renameFiles(list):
name = []
for filename in list:
name.append(re.split("(_\d*_\d*_\d*)", filename))
return name
def getFiles(list):
filelist = renameFiles(list)
dupes = getDupes(filelist)
print(dupes)
# move duplicated files to different folder
# os.rename(filename, moveto+filename)
# Try to find all duplicate files and return them in list
# each[0] is the filename
def getDupes(list):
dup = []
for each in list:
if each[0] in dup:
dup.append(each[0])
return dup
getFiles(list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment