Welcome to the Android Central Forums Create Your Account or Ask a Question Answers in 5 minutes - no registration required!
Results 1 to 1 of 1
  1. Thread Author  Thread Author    #1  

    Default Code to delete duplicate images from whatsapp gallery(or any galler)

    Instructions:
    1) Install QPython on Android phone
    2) Open Editor
    3) Copy Paste Code
    4) Edit folder_list.append statements with your respective directories. Add as many as you want.
    (Directory paths can be obtained using any file explorer app or AndroidZip)
    5) Click Save Button. Click Run button.



    import os, hashlib, Image
    from operator import itemgetter
    from itertools import groupby

    image_list = []
    folder_list = []
    folder_list.append(r'/storage/emulated/0/whatsapp/media/whatsapp images/')
    folder_list.append(r'/storage/emulated/0/whatsapp/media/whatsapp images/Sent')

    for folder in folder_list:
    file_list = os.listdir(folder)
    for img_file in file_list:
    file_path = os.path.join(folder, img_file)
    if os.path.isfile(file_path):
    try:
    sha1 = hashlib.sha1()
    sha1.update(Image.open(file_path).tostring())
    image_list.append([file_path, sha1.hexdigest()])
    except IOError:
    hjjj = "do nothing"

    image_list.sort(key=itemgetter(1))
    groups = groupby(image_list, itemgetter(1))
    for (img_hash, img_list_same_hash) in groups:
    z = [img for img in img_list_same_hash]
    i = 1 #Not deleting first element(index 0)
    while i < len(z):
    os.remove(z[i][0])
    print 'Deleted ' + z[i][0]
    i += 1

Similar Threads

  1. Helium app data from Nexus 7 (2012) to Nexus 5
    By AC Question in forum Ask a Question
    Replies: 1
    Last Post: 06-23-2014, 10:07 AM
  2. How to Root my 2012 Nexus 7 wi-fi only
    By AC Question in forum Ask a Question
    Replies: 3
    Last Post: 06-22-2014, 09:14 PM
  3. Has anyone tried changing their APN to IPv6.....
    By vWvSTATICvWv in forum T-Mobile
    Replies: 3
    Last Post: 06-22-2014, 08:12 PM
  4. Need to Create Google Play Playlists or Categories
    By AC Question in forum Ask a Question
    Replies: 7
    Last Post: 06-22-2014, 07:40 PM
  5. Cannot connect to gear
    By jay_dubb2k5 in forum Samsung Galaxy Gear
    Replies: 0
    Last Post: 06-22-2014, 01:08 PM

Posting Permissions