-
-
Save radosinsky/a2faf98fd207c2527895983899402c30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Finder" | |
set imagesFolder to "/Users/username/Downloads/keynote_image-grid_scripting/images" | |
set filesCount to number of files in folder (POSIX file imagesFolder as alias) | |
end tell | |
tell application "Keynote" | |
activate | |
tell the front document | |
set imagesReplaced to 0 | |
set imagesPerSlide to the count of images of slide 1 | |
set slidesCount to round filesCount / imagesPerSlide rounding up | |
repeat slidesCount - the (count of slides) times | |
duplicate slide 1 | |
end repeat | |
repeat with i from 1 to the count of slides | |
tell slide i | |
repeat with j from 1 to the count of images | |
set imageNumber to text -5 thru -1 of ("00000" & j + imagesReplaced) | |
set imagePath to imagesFolder & "/image_" & imageNumber & ".jpg" | |
try | |
set file name of image j to POSIX file imagePath as alias | |
on error | |
exit repeat | |
end try | |
end repeat | |
set imagesReplaced to imagesReplaced + the (count of images) | |
end tell | |
delete (every image of slide i where the file name is "placeholder.jpg") | |
end repeat | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment