Created
August 27, 2016 08:27
-
-
Save JunichiIto/88aa88d46a457361a84ab468d97183b2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
-- https://gist.github.com/natcl/7a5c98aae8b21475caf9 | |
log "start" | |
property imageFiles : {"jpg", "pef", "dng", "jpeg"} | |
tell application "Finder" | |
set MyFolder to folder POSIX file "/Users/your-path/" | |
set SubFolders to every folder of MyFolder | |
end tell | |
repeat with aFolder in SubFolders | |
log aFolder | |
set fl to files of aFolder | |
repeat with theItem in fl | |
log theItem | |
set theItemPath to POSIX path of (theItem as Unicode text) | |
set ImageFile to POSIX file theItemPath | |
set fileExtension to (name extension of theItem as Unicode text) | |
tell application "System Events" | |
if fileExtension is in imageFiles then | |
log "Import" | |
log ImageFile | |
tell application "Photos" | |
set DestinationAlbumName to "Inbox" | |
if not (exists container named DestinationAlbumName) then | |
log "make new album" | |
make new album named DestinationAlbumName | |
end if | |
log "Execute import" | |
import ImageFile into container named DestinationAlbumName with skip check duplicates | |
end tell | |
tell application "Finder" | |
log "Delete file" | |
log theItem | |
delete theItem | |
end tell | |
end if | |
end tell | |
end repeat | |
log "Delete folder" | |
log aFolder | |
delete aFolder | |
end repeat | |
log "end" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment