0

I'm trying to use a script that will run through a bunch of different folders and find Indesign files with "16x9" in the file name, and then loop them through a small AppleScript portion of code. I'm running into the problem where the result I receive is:

The file /Users/admin/Documents/00_Primary/Cordish/Cordish does not exist.

What I'm assuming is happening is that it's not accounting for the white space in the full file path. The full file path is this:

/Users/admin/Documents/00_Primary/Cordish/Cordish Horizontal/CordishAtlanta_Horizontal-16x9.indd

Here's what I have so far:

#!/bin/bash

FILES=find /Users/admin/Documents/00_Primary -name "*16x9.indd" -print0
for f in `$FILES`; do

    open -a "Adobe InDesign CC 2018" "$f"
    osascript <<'EOF'
tell application "System Events" to tell process "Adobe InDesign CC 2018"
    set frontmost to true
    delay 5
    tell application "System Events"
        key code 15 using {option down}
        delay 2
        key code 15 using {control down}
        delay 2
        key code 48
        delay .3
        key code 125
        delay .3
        key code 48
        delay .3
        key code 25
        delay .3
        key code 36
        delay 1
        key code 36
        delay .3
        key code 1 using {command down}
        key code 2
        delay .5
        key code 36
        delay 1
        key code 13 using {command down}
    end tell
end tell

EOF


done
1

What you need :

put the file processing in a script.sh, then :

find /Users/admin/Documents/00_Primary -name "*16x9.indd" -exec ./script.sh {} \;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.