2

I have written an apple script previously to automate a task I do in my work many times.

I shoot Raw + JPG in camera, copy to hard drive.

I then drag named and dated folder eg. "2019_08_14_CAM_A_CARD_01" on to an automator app and it divides the files in to folders "NEF" and "JPG" respectively.

I then drag the appropriate "JPG" folder onto my Timelapse app and it runs the image sequence process in QT7 and then saves the file with the parent folder name in the grandparent folder. This keeps things super organised for when I want to re link to the original RAW files.

[code below]

It is a 2 step process and works well for my needs, however, Apple are going to be resigning Quicktime 7 Pro so my app has a foreseeable end of life.

I want to take this opportunity to refine and improve the process using terminal and ImageMagick.

I have managed to work some code that runs well in terminal, but I have to navigate to the folder first then run a script. It doesn't do the file renaming and doesn't save in the right place.

Also, when I try and run the simple script in an automator 'App' it throws up errors even before trying to add anything clever with the file naming.

Later, once I have recreated my timelapse. maker app I want to get clever with more of ImageMagicks commands and overlay a small super of the original frame name in the corner so I can expedite my reconnecting workflow.

I'm sorry, I'm a photographer not a coder but I've been bashing my head trying to work this out and I've hit a brick wall.

File Sorter

    repeat with d in dd
        do shell script "d=" & d's POSIX path's quoted form & "
cd \"$d\" || exit

mkdir -p {MOV,JPG,NEF,CR2}
find . -type f -depth 1 -iname '*.mov' -print0 | xargs -0 -J % mv % MOV
find . -type f -depth 1 -iname '*.cr2' -print0 | xargs -0 -J % mv % CR2
find . -type f -depth 1 -iname '*.jpg' -print0 | xargs -0 -J % mv % JPG
find . -type f -depth 1 -iname '*.nef' -print0 | xargs -0 -J % mv % NEF

for folder in `ls`; 
do if [ `ls $folder | wc -l` == 0 ]; then 
    rmdir $folder;
fi; done;

"
    end repeat
end open```



Timelapse Compiler

```on run {input, parameters}
    repeat with d in input
        set d to d's contents
        tell application "Finder"
            set seq1 to (d's file 1 as alias)
            set dparent to d's container as alias
            set mov to "" & dparent & (dparent's name) & ".mov"
        end tell
        tell application "QuickTime Player 7"
            activate
            open image sequence seq1 frames per second 25
            tell document 1
                with timeout of 500 seconds
                    save self contained in file mov
                end timeout
                quit
            end tell
        end tell
    end repeat
    return input
end run```


Current code that runs from within Terminal after I have navigated to folder of JPGs

```ffmpeg -r 25 -f image2 -pattern_type glob -i '*.JPG' -codec:v prores_ks -profile:v 0 imagemagick_TL_Test_01.mov```
  • Interesting problem, but **too broad** by stackOverflow standards. So you're trying to convert code above into just a basic linux (or MACOS) script? (specify which and add a tag as appropriate). Thats a lot of code. Don't try to get it all working at once. The `mkdir`, `find .. mv` should still work. If there are several different tools that are using the code above, that is not clear. Try to improve the formatting so it is clear what tool is using what code. Start much smaller and keep adding things. When you get stuck on one problem, post a new Q. .... – shellter Aug 14 '19 at 16:44
  • A good Q will focus on one problem. We don't need to see 1000s of the same file or input, just 2 small lines/files good data, 1 line/file of bad data (that should generate an error or not be processed). Then show the required ouput or transformation (or action) required from those inputs. Show your code, your current output/transformation/action and any error messages. Feel free to add comment `@shellter, look at this will you` and I'll see if I can help. Good luck. – shellter Aug 14 '19 at 16:46
  • Thank you @shellter . I listed the existing code/apps as ?I thought it would explain what I'm trying to achieve. The code ```ffmpeg -r 25 -f image2 -pattern_type glob -i '*.JPG' -codec:v prores_ks -profile:v 0 imagemagick_TL_Test_01.mov``` is what I have figured out will work in Terminal if I first navigate to the folder and run the action. I'm justifying to get that to work in an app so I can drag a folder on and it runs the FFmpeg script. – cursor_major Aug 15 '19 at 09:04
  • Once I can run this I will build in the other components from my older 'Apps' but I can't even get the FFmpeg code to run once I try to place it in apple script editor or automator with run shell script. – cursor_major Aug 15 '19 at 09:08
  • I think you want to change up some of your tags. Definitely something to indicate which shell you are using, as [shell] is generic. And, either you are looking ot convert applescript code to ? or continue using applescript, you'd do well to use a tag for that. Finally, as you seem committed to Mac you need a tag to get your fellow mac-ites looking at your Q. OR you could delete here and repost to https://apple.stackexchange.com . Good luck. – shellter Aug 15 '19 at 12:13

0 Answers0