Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pavvel

macrumors regular
Original poster
Jul 18, 2013
221
339
Hi guys,

Bit of a long shot but wondering if someone can help.

I have backed up my iMessage attachment folder with a whole load of pictures. I would like to save these pictures into one folder but as you may know it lays them out in a sub>sub>sub type folder for each picture. Is there anyway or any app that lets you grab the file out of the parent folders and sub folders and put them into one? There is so many by hand this would take forever.

Thanks.
 
If you don't mind using bash commands, here you go:

Open Terminal, type "cd", then a SPACE, then drag&drop your folder from Finder, so it looks like this:
Code:
cd /Your/backup/folder
press enter, this will change your working directory to the one you specified. Then copy&paste this:
Code:
mkdir FILES; find . -type f -exec cp {} ./FILES/ ";"
and press enter, this will find any FILES (type f) in your working directory (.) and any subfolders and copy them (cp {}) into a folder named FILES.

Tested and works.
 
Thank you for the reply. Where will the folder FILES end up so I can see the result?
 
Forget that I worked it out. What if the file names are the same and when they are pulled into the same folder they don't copy. Is there anyway around this?
 
Maybe, try using this instead of the second one:

Code:
mkdir FILES; find . -type f >> temp;
for file in `cat temp`;
do filenew="$file";
cp -n "$file" ./FILES/;
if [ $? -eq 1 ] ; then
filenew="$file"`md5 $file | cut -d'=' -f2`;
cp -n "$file" "./FILES/${filenew##*/}";
fi;
done;
rm -r temp;

I guarantee nothing, btw :D

Edit: What I did is i told the script to append a MD5 checksum to the filename if the copy command tries to overwrite a file with the same filename. It took me an hour :D I do need to brush up on my bash skills.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.