OS X folder splitter

JonathanRyan

Suspended / Banned
Messages
10,765
Name
Jonathan
Edit My Images
Yes
I need an app that will allow me to copy every THIRD file from a folder into another folder. Ideally it would copy every nth file. Any ideas?

It looks like the thing that would be easy to script but I'm not that good at scripting. Big Mean Folder Machine won't do this sadly.
 
Use Automator, it's a graphical user interface provided by Apple where you can point and click and build your scripts :thumbs:
 
I read your job offer post and you stated that you use Photo Mechanic. Howsabout...(it's a bit of a kludge, but it works)...

Set PM to display only 3 images per line (I simply reduced the size of the contact sheet), then cmd-click on the 3rd image and while still holding down the 'cmd' key move the cursor downwards (it will select every third image), when the cursor hits the bottom of PM's application frame the contact sheet will scroll down at speed - selecting every third image as it scrolls. Then you can simply cmd-y to copy these selected images.

It's w-a-y easier to do than to explain!

In a very quick and unscientific test, it just took me around 7 seconds to select 100 images out of 300 hundred.

It's not an elegant solution, but it should work.
 
@dejongj has posted the ideal solution - very neat and tidy.

As an alternative, roll up your sleeves and create a Bash script along the following lines...

#!/bin/bash
DESTDIR=/home/user/somedir
COUNT=1
for FILE in * ; do
if [ $COUNT -eq 3 ] ; then
mv $FILE $DESTDIR
let COUNT=1
else
let COUNT+=1
fi
done
It's rough and dirty and won't take prisoners. I love Applescript but struggle with the syntax (it's an age thing).
 
LOL @adrianday I would do a similar thing as well, or use a bit of python or ruby script depending on what I need to do :thumbs: But as we agree AppleScript, and dare I say the Automator tool, makes it really easy to automate tasks....
 
LOL @adrianday I would do a similar thing as well, or use a bit of python or ruby script depending on what I need to do (y) But as we agree AppleScript, and dare I say the Automator tool, makes it really easy to automate tasks....
I love Automator. Spent a few months a while back in the middle of the South Atlantic. Internet access was limited and expensive asides from a window between midnight and 6:00am when data wasn't metered. Cue Automator laced with some Applescript. Machine wakes up. Turns on the WiFi. Turns on the VPN. Starts some other services (;)). Then, just before 6:00am, shuts everything down neatly. Happy times.
 
I read your job offer post and you stated that you use Photo Mechanic. Howsabout...(it's a bit of a kludge, but it works)...

Set PM to display only 3 images per line (I simply reduced the size of the contact sheet), then cmd-click on the 3rd image and while still holding down the 'cmd' key move the cursor downwards (it will select every third image), when the cursor hits the bottom of PM's application frame the contact sheet will scroll down at speed - selecting every third image as it scrolls. Then you can simply cmd-y to copy these selected images.

Hmm. VERY interesting (because ATM I'm using PM and CMD-clicking every third image). But I can't get this to work :( When you say "move the cursor downwards" - exactly how are you moving it? I've tried mouse wheel and arrow keys.

I was thinking of writing it for you, but then I found it all layout out in apple support.

https://discussions.apple.com/thread/5553356?tstart=0

Have fun.

Ah - SPLENDID. Thank you. One day I should roll my sleeves up and learn Applescript. Despite Automator, it doesn't seem to be getting killed off any time soon.
 
@dejongj has posted the ideal solution - very neat and tidy.

As an alternative, roll up your sleeves and create a Bash script along the following lines...

#!/bin/bash
DESTDIR=/home/user/somedir
COUNT=1
for FILE in * ; do
if [ $COUNT -eq 3 ] ; then
mv $FILE $DESTDIR
let COUNT=1
else
let COUNT+=1
fi
done
It's rough and dirty and won't take prisoners. I love Applescript but struggle with the syntax (it's an age thing).

Thanks - that actually looks like something I can understand (I find Applescript slightly confusing but then I've never bothered learning it). But the Applescript is working perfectly so I can stay away from Bash :) and with Automator I think I can attach it as a folder service so I can run by right clicking.

As a small mod I need to start from the second file and select every 3rd one but even I can manage stuff like that ;)
 
Hmm. VERY interesting (because ATM I'm using PM and CMD-clicking every third image). But I can't get this to work :( When you say "move the cursor downwards" - exactly how are you moving it? I've tried mouse wheel and arrow keys.
I've sent you a personal message with a link to a screen recording I made which will (hopefully) illustrate this easy peasy thing.

Obviously it's somewhat superfluous as you've received far superior advice from others here.
 
LDR preview renders of HDR images, innit?
Ah. If the files you want to move have a different name (or file extension) you could simply filter by that instead of moving every 3rd file. It'd reduce the risk of moving the wrong files.
 
LDR preview renders of HDR images, innit?
And the software that created them didn't give you any choice over where to put them? Or any option to give them distinctive names so that you could later identify them en masse?
;)
 
Last edited:
I would switch to list view and sort the folder by date modified. All the renders are going to be newer than the pictures they came from, so will end up together.
Ah. If the files you want to move have a different name (or file extension) you could simply filter by that instead of moving every 3rd file. It'd reduce the risk of moving the wrong files.
And the software that created them didn't give you any choice over where to put them? Or any option to give them distinctive names so that you could later identify them en masse?
;)

Ah no. All of that would be far too easy ;) If I wanted to select the renders then I could sort by time created, size, filename or even just dump them in a different folder.

Here's what I actually meant.... I shoot large numbers of HDR panoramas for virtual tours. These usually have 3 shot HDR repeated in 4 directions so 12 shots per 360 panorama. To build the scene I need all 12 shots. But for a quick and dirty LDR preview I only need 4 of the images and rendering HDR takes a long time on my laptop. Same thing if I chuck all 12 images at PTGui - it takes at least 3X as long as it need to.

So, I typically want the second image and then every third image from one folder to put into PTGui. The easiest way to do that is duplicate them to another folder and then let Batch Builder have at them while I do something more interesting. I've been doing that manually but it's surprisingly error prone when you have large number of images to chuck around. (Tough see @TonyHall 's shortcut above)
 
I've sent you a personal message with a link to a screen recording I made which will (hopefully) illustrate this easy peasy thing.

Obviously it's somewhat superfluous as you've received far superior advice from others here.

Finally I've got it - thank you. FWIW using the mouse roller doesn't work for this ;)

In the spirit of giving back, here's where I am with my Applescript. Give it a folder and it will split it into jpegs and raws and then copy the second jpeg and every 3rd one to another folder for PTGui to use. Obviously you could tinker with those numbers or pass parameters if you're shooting 5 or 9 step HDRs. It assumes you have a folder in your home called "temp" - doesn't everyone? If not just follow the procedure for creating the ldrfolder but remember not to delete the files ;) (Really, this is all at your own risk. If you're daft enough to use a piece of Applescript posted in a forum without understanding it then don't blame me if it bricks your Mac)

Code:
set sourceFolder to choose folder with prompt "Select Source Folder"

tell application "Finder"
   
    # get the folder where the new files are
    set homeFolder to home as string
   
    # create a new blank folder for the LDR files
   
    set tempFolder to (homeFolder & "temp")
    set ldrFolder to (tempFolder & ":PTGui_test")
    if (exists folder (ldrFolder)) = false then
        make new folder at tempFolder with properties {name:"PTGui_test"}
    else
        delete (files of folder ldrFolder)
    end if
   
    # split the new files into jpegs and raws
   
    if (exists folder (sourceFolder & "jpegs" as string)) = false then
        make new folder at sourceFolder with properties {name:"jpegs"}
    end if
    if (exists folder (sourceFolder & "raws" as string)) = false then
        make new folder at sourceFolder with properties {name:"raws"}
    end if
    move (every file of sourceFolder whose name extension is "jpg") to folder "jpegs" of sourceFolder
    move (every file of sourceFolder whose kind contains "raw image") to folder "raws" of sourceFolder
   
    # copy every third jpeg to the LDR folder
   
    set theFiles to the files of folder (sourceFolder & "jpegs" as string)
    repeat with n from 2 to (count of theFiles) by 3
        duplicate item n of theFiles to folder the ldrFolder
    end repeat
   
    # show results in finder
    activate
    if window 1 exists then
        set target of window 1 to ldrFolder
    else
        reveal ldrFolder
    end if
end tell
 
Back
Top