How to one sort files without knowing their extension

automatorfinder

I have recently been having an issue moving a backup of an iPhone to a new iPhone. After many hours spent with Apple Support I've determined it's a lost cause, but I have the backup and am able to view the files in the backup, including my pictures. I was wondering if anyone knew how to sort these files using Automator so I can have all the pictures in one folder. I I have tried using the "Kind is image" filter, but that will only work if the extension is an image extension, and since none of the files have any extension this will not work.

Best Answer

Don't need to use Python, you can do this on the command-line command: file

eg.

$ file *
Sams.jpg:               JPEG image data, JFIF standard 1.01, aspect ratio, density 72x72, segment length 16, Exif Standard: [TIFF image data, big-endian, direntries=10, manufacturer=Apple, model=iPhone 7, orientation=upper-left, xresolution=150, yresolution=158, resolutionunit=2, software=Photos 1.5, datetime=2016:11:13 14:09:31, GPS-Data], baseline, precision 8, 4032x3024, frames 3

So, you can dump that data out, and sort it for the paths you want.

eg.

alex@smiley:~|⇒  find . -type f -exec file {} \;
./.bash_history: ASCII text
./.bash_login: ASCII text
./.bash_profile: ASCII text
./.bashrc: ASCII text
./.bashrc.bak: ASCII text
./.cache/fontconfig/0f0db7876307790c19e1f91eb9095080-le64.cache-4: data
./.cache/fontconfig/1487dd4aecf3164c4a11193169052443-le64.cache-4: data
./.cache/fontconfig/2d5afd1bf94294700ac1600496f0236c-le64.cache-4: data
./.cache/fontconfig/3f80be19c668e16fc38439c9c84a1bc7-le64.cache-4: data
./.cache/fontconfig/49aa604a5ac92994756d3008e408245c-le64.cache-4: data
./.cache/fontconfig/558352270fb122ca08359d23b5a778d4-le64.cache-4: data

etc.

Filter the output for images, using grep:

From the directory storing your back-ups:

find . -type f -exec file {} \; | grep image

alex@smiley:~|⇒  find . -type f -exec file {} \; | grep image
./.gradle/caches/minecraft/assets/objects/92/92750c5f93c312ba9ab413d546f32190c56d6f1f: PNG image data, 32 x 32, 8-bit/color RGBA, non-interlaced
./.gradle/caches/minecraft/assets/objects/bd/bdf48ef6b5d0d23bbb02e17d04865216179f510a: PNG image data, 16 x 16, 8-bit/color RGBA, non-interlaced