Created
April 5, 2019 13:01
-
-
Save jxmorris12/ad8ef9675b43280b9124ff5bd5708785 to your computer and use it in GitHub Desktop.
Copy all pictures from iMessage on Mac to current folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# needs python 3.5+ | |
import glob | |
import os | |
def sh_escape(s): | |
return s.replace("(", "\\(").replace(")","\\)").replace(" ","\\ ") | |
home = '/Users/myusername' | |
glob_path = home + '/Library/Messages/Attachments/**/*' | |
files = [] | |
for ext in ['png', 'jpeg', 'jpg']: | |
print(glob_path + ext) | |
files.extend(glob.glob(glob_path + ext, recursive=True)) | |
EXT = ext.upper() | |
files.extend(glob.glob(glob_path + EXT, recursive=True)) | |
for filename in files: | |
cmd = 'cp -p {} .'.format(sh_escape(filename)) | |
os.system(cmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
iMessage stores all images in subfolders of ~/Messages/Attachments. It's not meant to be user-facing, but it can be. I ran this script to back up all my images from past text messages before wiping my laptop.