Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. //Add this code to a new ‘Quick Action’ in ‘Automator’ and assign a keyboard shortcut to it for ideal workflow.
  2. //by Rick Companje, May 2019
  3.  
  4. var app = Application("Photos")
  5. app.includeStandardAdditions = true
  6. var sel = app.selection();
  7.  
  8. if (sel.length>0) {
  9.  
  10. //show list with all album names ordered
  11. var names = app.albums.name(); //original order for index
  12. var namesWithIndex = names.map(function(el,index) { return el + " #" + index; });
  13. var namesSorted = namesWithIndex.sort();
  14. var result = app.chooseFromList(namesSorted, { withPrompt: sel.length + " foto's toevoegen aan een bestaand album?" })[0];
  15.  
  16. if (result) { //if album was choosen then add selected photos to that album
  17. var index = parseInt(result.substr(result.lastIndexOf('#') + 1));
  18. var selectedAlbum = app.albums.at(index);
  19. app.add(sel, {to: selectedAlbum });
  20.  
  21. } else { //else (on cancel/escape) ask to create a new album
  22.  
  23. var result = app.displayDialog("Nieuw album maken?", { defaultAnswer: "", withIcon: 1 })
  24. if (result) {
  25. var album = app.make({new: "album", named: result.textReturned, at: app.folders.byName("Overig") });
  26. app.add(sel, {to: album });
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement