Go Back   The macosxhints Forums > OS X Help Requests > Applications



Reply
 
Thread Tools Rating: Thread Rating: 12 votes, 5.00 average. Display Modes
Old 07-02-2002, 02:57 PM   #1
kerim
Major Leaguer
 
Join Date: Jan 2002
Posts: 311
Question iPhoto Extraction?

I would like to quickly extract all my photos from iPhoto's library and move or copy them to another directory. So far I've come up with this terminal command:

Code:
find /Volumes/MCE\ FW\ HD/ |grep .jpg
But the problem is that it doesn't exclude images in the "Thumbs" directories. Also, it only "finds" the images, it doesn't copy them anywhere. Any help would be appreciated.

I don't want to start any flames, but I really have had a bad time with iPhoto. I find it very cumbersome and slow (on my dual USB iBook) for managing a large library of information. I wish it worked more like iTunes in that the EXIF tag info alone was used to sorting the photos, rather than putting them into sub folders, assiging a limited number of keywords, rolls, etc. it all becomes quite unwieldly. I tried using iPhotoLibraryManager - but since upgrading to 1.1.1 all my libraries are messed up and don't even show my photos (which are in the right place on the HD). Sorry for the rant, but now I'm upset that extracting my PHotos out of these numerous sub-folders is such a pain! I wish there was something like MP3 Rage for jpgs.
kerim is offline   Reply With Quote
Old 07-02-2002, 04:34 PM   #2
griffman
MVP
 
Join Date: Dec 2001
Location: Portland, OR
Posts: 1,472
Well, you could just select all in the iPhoto main window and select File -> Export (make sure that there's no scaling applied), and then specify a new destination. This should copy everything from the various subdirectories to the new location.

Or you could use Sherlock and search for "IMG_", as that's what all the iPhoto images are named. When the list comes up, select all and drag to the new location.

If you really want to do it in the Terminal, though, I'm sure it's possible. You can easily find all the images with (assuming you are in the main iPhoto Library directory) find . -name "IMG_*". This will return a list of all matching files. To actually copy them somewhere, though, you'd need a short script to handle the repetition ... and that's beyond my skill level!

But if all you want is the images out, then either Sherlock or iPhoto itself seems like the easiest solution.

-rob.
griffman is offline   Reply With Quote
Old 07-02-2002, 04:39 PM   #3
kerim
Major Leaguer
 
Join Date: Jan 2002
Posts: 311
Can't use iPhoto because the images don't appear in iPhoto (that is why I want to move them in the first place). The images are in the folders, but do not appear in iPhoto.

Sherlock crashed on me twice when I tried to use it in this way.
kerim is offline   Reply With Quote
Old 07-02-2002, 06:30 PM   #4
griffman
MVP
 
Join Date: Dec 2001
Location: Portland, OR
Posts: 1,472
Doh ... it's much easier than I thought it would be (thanks to a buddy for straightening out my thoughts). I was trying to get around complications that don't exist. The following should work (it did in my testing). You need to be in the main iPhoto Library directory, and then issue this command:

mv `find . -name "IMG_*"` /path/to/new/location

So if you were moving everything to a new "iPhoto_pix" folder on your desktop, it would look like:

mv `find . -name "IMG_*"` ~/Desktop/iPhoto_pix

If you want to test this first, put an "echo" in front of the whole command, and the output should be a really long "mv" command that won't be executed.

-rob.
griffman is offline   Reply With Quote
Old 07-02-2002, 07:08 PM   #5
kerim
Major Leaguer
 
Join Date: Jan 2002
Posts: 311
The find command works fine (except I use *.jpg instead of IMG, because iPHoto has not renamed my files in this way, but this creates a problem in that it doesn't distinguish between thumbnails and images files). However, the mv command does not work in this way - I get an error every time. In any case, I would prefer to copy files as opposed to moving them.
kerim is offline   Reply With Quote
Old 07-02-2002, 07:23 PM   #6
kerim
Major Leaguer
 
Join Date: Jan 2002
Posts: 311
More precisely, this is the error I get:

Quote:
mv: rename find -name "*.jpg" to /Users/kerim/Pictures//find -name "*.jpg": No such file or directory

kerim is offline   Reply With Quote
Old 07-02-2002, 07:57 PM   #7
griffman
MVP
 
Join Date: Dec 2001
Location: Portland, OR
Posts: 1,472
To copy instead of move, just use "cp" instead of "mv". Can you copy and paste the actual entry of the command and the output it returns? It's hard to diagnose the problem from the output of the error without seeing the input -- I just tested it again by copying and pasting from my previous post, and it worked...

-rob.
griffman is offline   Reply With Quote
Old 07-02-2002, 08:17 PM   #8
kerim
Major Leaguer
 
Join Date: Jan 2002
Posts: 311
Cool

Amazing. I copied your command from the forum instead of retyping it and it worked. I guess that is why they are working so hard to give UNIX a GUI!!! But I have to say that this worked much better and faster than going from Sherlock! (Which is what I've been doing bit by bit all afternoon ....) Thanks!
kerim is offline   Reply With Quote
Old 07-02-2002, 08:18 PM   #9
AKcrab
MVP
 
Join Date: Jan 2002
Location: Wasilla, AK
Posts: 1,043
Quote:
Originally posted by kerim
More precisely, this is the error I get:


I think it's "find."... I don't see the '.'...
(just my guess)
AKcrab is offline   Reply With Quote
Old 07-02-2002, 08:19 PM   #10
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
Quote:
Originally posted by kerim
More precisely, this is the error I get:

------------------------------------------------------------------------
mv: rename find -name "*.jpg" to /Users/kerim/Pictures//find -name "*.jpg": No such file or directory
------------------------------------------------------------------------

this indicates that you've entered the 'find' command and args unsurrounded by the backticks.

before you proceed any further, make a backup (drag & drop) copy of your iphoto library somewhere outside the path of the find command. this is so you can recover easily from 'fat fingers'

kerim, enter the command thusly, paying particular attention to the quoting...
Code:
mv `find . -name "IMG_*"` /path/to/new/location
note:

the backticks ( ` ) and doublequotes ( " ) are necessary to make it work correctly.

make sure /path/to/new/location is outside of the path your traversing with the find command, which should be ~/Pictures , i guesss, if that's where your iphoto lib is.

and i would just use copy ( cp ) until you're satisfied with the results.

and, i would test it with rob's suggestion of prepending the entire command with an 'echo' command so you can see what it's going to do.

if you want to filter out small 'thumbnail' images, you can complement the find with a filter action -size +numberOfBlocks , but you'll need to know the magic number where thumbnailSize < number < yourImagesSize.

or, you could just move/copy all then use a finder list view sorted by size to determine small 'thumbnails'

[edit: i see you've already had some success

AKcrab, the dot ( . ) indicates "current dir" and should have spaces around it to notate such.]

Last edited by mervTormel; 07-02-2002 at 08:24 PM.
mervTormel is offline   Reply With Quote
Old 07-02-2002, 08:21 PM   #11
kerim
Major Leaguer
 
Join Date: Jan 2002
Posts: 311
I also found this great Freeware application that renames all of your photos based on the EXIF info. The only thing I need now is some way to group all the photos from the same day into folders... Any ideas?

http://www.versiontracker.com/morein...d=12577&db=mac
kerim is offline   Reply With Quote
Old 07-02-2002, 08:31 PM   #12
kerim
Major Leaguer
 
Join Date: Jan 2002
Posts: 311
Thanks for your (as usual) clear and informed reply. This tip will be especially useful! I think all images 20KB and under are thumbnails, although I'm not 100%

Quote:
Originally posted by mervTormel

this indicates that you've entered the 'find' command and args unsurrounded by the backticks.

before you proceed any further, make a backup (drag & drop) copy of your iphoto library somewhere outside the path of the find command. this is so you can recover easily from 'fat fingers'

kerim, enter the command thusly, paying particular attention to the quoting...
Code:
mv `find . -name "IMG_*"` /path/to/new/location
note:

the backticks ( ` ) and doublequotes ( " ) are necessary to make it work correctly.

make sure /path/to/new/location is outside of the path your traversing with the find command, which should be ~/Pictures , i guesss, if that's where your iphoto lib is.

and i would just use copy ( cp ) until you're satisfied with the results.

and, i would test it with rob's suggestion of prepending the entire command with an 'echo' command so you can see what it's going to do.

if you want to filter out small 'thumbnail' images, you can complement the find with a filter action -size +numberOfBlocks , but you'll need to know the magic number where thumbnailSize < number < yourImagesSize.

or, you could just move/copy all then use a finder list view sorted by size to determine small 'thumbnails'

[edit: i see you've already had some success

AKcrab, the dot ( . ) indicates "current dir" and should have spaces around it to notate such.]

kerim is offline   Reply With Quote
Old 07-02-2002, 09:21 PM   #13
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
more command line fun

Quote:
Originally posted by kerim
Thanks for your (as usual) clear and informed reply. This tip will be especially useful! I think all images 20KB and under are thumbnails, although I'm not 100%

yer welcome.

i think that 20KB is the magic size, but what is that in the 'find -size +blocks' ?

that would be 40 blocks, i think...

$ zcalc 20*1024/512
40

generally, take the target size and double it; if it's MB instead of KB, add three zeros.

note that the find command has a -exec switch which could accomplish this a la...
Code:
% find /pathTo/source/ -type f -name "*.jpg" -size +40 \
    -exec echo cp \"{}\" /pathTo/target/ \;

cp "/pathTo/source/attitude problem.jpg" /pathTo/target/
cp "/pathTo/source/BBQ flyer.jpg" /pathTo/target/
cp "/pathTo/source/bookOfTikiFront.jpg" /pathTo/target/
note that the above is just an echo (display) of the command that would be run. after you're satisfied with the crafted command, remove the echo and let her buck.

also note, the escaped quotes ( \"{}\" ) enable the exec'd command to not puke on filenames with spaces.
mervTormel is offline   Reply With Quote
Old 07-02-2002, 10:13 PM   #14
kerim
Major Leaguer
 
Join Date: Jan 2002
Posts: 311
OK, so most of my photos are now in a single folder and have been named based on the date and time in the EXIF info (unfortunately, it seems that some photos lost their EXIF info along the way ...). Now I would like to group all the photos taken on the same day into folders named with that date.

Here is a sample of the file name list so you can see what it looks like:

2000-10-05_21-32-04.jpg
2000-10-05_21-32-10.jpg
2000-10-05_22-13-28.jpg
2000-10-05_22-14-53.jpg
2000-10-05_22-17-44.jpg
2000-10-05_22-18-02.jpg
2000-10-06_10-38-42.jpg
2000-10-17_01-39-12.jpg
2000-10-17_01-39-26.jpg
2000-10-17_01-40-44.jpg
2000-10-17_01-46-06.jpg
2000-10-17_01-58-17.jpg
2000-10-17_01-58-25.jpg
2000-10-17_01-58-39.jpg
2000-10-17_01-58-51.jpg
2000-10-17_01-59-21.jpg
2000-10-17_02-02-19.jpg
2000-10-17_02-09-20.jpg

... etc. There are about 1,700 photos, so it would be nice to have a script that would automate this process! Thanks to anyone who can offer some suggestions.

note: The idea being that the folders would be named:

Photos 2000-10-17
Photos 2000-10-06
etc.
kerim is offline   Reply With Quote
Old 07-03-2002, 12:10 AM   #15
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
kerim,

this can be done with a full blown script that requires a little preparation up front.

i'll start with a hint, then we can expound on it.
Code:
#!/bin/sh

sourceDir=/pathto/source/
targetDir=/pathto/target/

# note that pathto target must not be in pathto source, right?

for f in `find ${sourceDir} -type f -name "*.jpg"`
do

  get the base filename

  peel out the yyyy-mm-dd part

  mkdir "targetDir/photo yyyy-mm-dd"

  move the file we're working on to the dir we just made

done
mervTormel is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 11:57 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.