-
All replies
-
Helpful answers
-
May 4, 2015 3:12 PM in response to R C-Rby turingtest2,I'd read up on case sensitivity too and both theory and practice (in my case) said I didn't need to worry about it, but perhaps it would be better if I made it explicit. As for substring searches I'd thought about it, but I've assumed until I know otherwise that there isn't a potential for a clash within the relatively limited set of valid image entensions. I've yet to explore more deeply but in my vbScripts I sometimes wrap the values with vertical bars, e.g. "|.jpg|.mov|.png|.tif|" and then add them to the search term. VBS doesn't have anything that looks as efficient if element is in list, on the other hand I've found that AppleScript doesn't seem to like some nested clauses which I would normally use to avoid having to declare variables to hold intermediate results. I shall find out what works and what doesn't.
tt2
-
May 4, 2015 4:16 PM in response to turingtest2by R C-R,turingtest2 wrote:
VBS doesn't have anything that looks as efficient if element is in list, on the other hand I've found that AppleScript doesn't seem to like some nested clauses which I would normally use to avoid having to declare variables to hold intermediate results.
Handling lists seems to me to be one of Applescript's most powerful features, but I have admit I often find them hard to work with, particularly when lists of lists are involved.
-
May 4, 2015 4:24 PM in response to Old Toadby R C-R,Old Toad wrote:
I noticed that the second line I've been working with is "Set to include" which keeps .cr2 in the title. I removed that line, keeping .cr2 in the line above, and got the following error message.
I assume you mean "set include to" & not "set to include" but since the include variable is used later in the script (in the if (offset of ext in include) > 0 and not ext = postfix then statement) the script will error out with that message whenever it tries to execute it.
That much I understand. The rest of it, not so much.
-
May 5, 2015 4:01 PM in response to R C-Rby JaneTeis,This is too complicated for me. I don't do any applescript or programming. Why can't Apple just let us show the FILENAME under each photo? I don't want to have to type some "Add a Title" to every photo.
-
May 5, 2015 6:10 PM in response to JaneTeisby R C-R,JaneTeis wrote:
This is too complicated for me. I don't do any applescript or programming. Why can't Apple just let us show the FILENAME under each photo? I don't want to have to type some "Add a Title" to every photo.
Only Apple can say why Apple made the change but the reality is that filenames & titles are two very different things, & iPhoto (& thus Apple) never did users any favors by obscuring that difference.
-
May 13, 2015 2:46 PM in response to léonieby Allison Sheridan,léonie - very cool what you've done here for us! I can use the script you've written to change the descriptions, and I can use the script you've written to change the titles to the file names. Both work great. However, they're just shy of what I want. Let's say I go to Germany for a vacation and on day one I go to Hamburg. I would like to batch change the titles to all say either Hamburg, or even better sequential titles of 01_Hamburg, 02_Hamburg.
I've tried modifying your script just to change the title to the input text but I must be messing up the syntax. Here's one version I've tried (that does nothing at all!)
on run {input, parameters}
tell application "Photos"
activate
set imageSel to (get selection)
if imageSel is {} then
error "Please select an image."
else
repeat with im in imageSel
set title to the name of im
if not (exists (title)) then
set the name of im to the filename of im
end if
end repeat
end if
end tell
end run
Appreciate any help you can give me finding my mistake. If you want to help me kick it across the goal line and add that index number too that would be swell!
thanks!
Allison Sheridan
NosillaCast Mac Podcast at http://podfeet.com
-
May 13, 2015 3:27 PM in response to Allison Sheridanby R C-R,Your script does nothing because you set the title to the name of the selected image ("im" in the script repeat loop) & then tested for it not existing in the "if not (exists (title)) then" step. Because of that, it will always exist (even if the name is the empty text string "") & the name won't be changed.
You might try léonie's Batch Changes in Photos for Mac: Change the titles to a Given String Automator service -- it looks like it does what you want without the need for any modifications.
-
by Old Toad,May 13, 2015 4:19 PM in response to Allison Sheridan
Old Toad
May 13, 2015 4:19 PM
in response to Allison Sheridan
Level 10 (140,881 points)
Photos for MacLet's say I go to Germany for a vacation and on day one I go to Hamburg. I would like to batch change the titles to all say either Hamburg, or even better sequential titles of 01_Hamburg, 02_Hamburg.
Try this script:
on run {input, parameters}
-- batch change the title to the input, © léonie, version 1.0.1
set n_digits to 2 -- how many digits for the appended number
set answer to display dialog "Select the number of digits for the appended numbers (0 .. 10). Selecting '0' will suppress the leading zeros." buttons {"o.k"} default answer n_digits
-- For 1-9 photos use 2. For 10 to 99 photos use 3 and for 100 or more photos use 4.
set n_digits_text to the (text returned of answer)
set n_digits to n_digits_text as number
tell application "Photos"
activate
set counter to 1
set imageSel to (get selection) -- get selected images
if imageSel is {} then
error "Please select some images."
else
repeat with im in imageSel
set ntext to the counter as text
repeat while (the length of ntext < n_digits) -- add leading zeros
set ntext to "0" & ntext
end repeat
tell im
set the name to input & "-" & ntext as text
-- set the title to the input plus formatted number
set counter to counter + 1
end tell
end repeat
end if
end tell
return "Done. The titles of " & (length of imageSel) & " photos have been changed."
end run
and use it in this Automator workflow application:
The first window you'll get is this where you'll put in the title
The next window is this which sets the number of digits for the sequential number:
Which gives you this for the titles:
-
May 13, 2015 4:49 PM in response to Old Toadby R C-R,That script could also easily be modified to put the numbers first in the title & use an underscore instead of a dash as a separator. Just change this line:
set the name to input & "-" & ntext as text
to this:
set the name to (ntext as text) & "_" & input
-
May 13, 2015 5:09 PM in response to Old Toadby Old Toad,I prefer the dashes because they were easier to use when having to do it manually.
I've added that workflow to the Photos User Tips with a link to download the app if the visitor doesn't want to create it themselves.
-
May 16, 2015 10:43 AM in response to Old Toadby Allison Sheridan,When I run the Title script it queries me for what name I want and it queries for how many digits. However it sends a generic error to the screen and says, “want me to show you the workflow?”
There’s only 2 steps here - one is to get the images, two is to rename them, so I tried adding a speech thing in between the two steps to see where it was failing and it does do the speech. I tried looking at the details as the script ran and all it does is give me a red x error, with no details.
I feel like one of those people who simply write back, "it didn't work" but I can't figure out how to diagnose this. Note that the change description script DOES run properly.
?
-
by Old Toad,May 16, 2015 11:32 AM in response to Allison Sheridan
Old Toad
May 16, 2015 11:32 AM
in response to Allison Sheridan
Level 10 (140,881 points)
Photos for MacDid you build the app yourself or download it from the User Tip?
-
May 16, 2015 11:40 AM in response to Allison Sheridanby Jay Deitch,Do you have "All Photos" selected under Albums in the sidebar instead of "Photos" at the very top? I can't get the scripts to work if "Photos" is selected, but does if the photos are selected in "All Photos."
Jay
-
May 16, 2015 10:05 PM in response to Old Toadby Allison Sheridan,Old Toad - downloaded from the user tip.
Jay Deitch - YOU GOT IT! I had selected Photos and it didn't run. Just selected All Photos and it DID run. Apple is driving me bonkers with their naming conventions lately.
thank you all so much! Especially léonie for writing the scripts. I think I'm going to have a gift to bring back to the thread. A friend of mine wrote a script for me that does something cool. I'm going to leave you with a tease for now because she's off on her boat in Alaska and I can't ask her permission yet to publicize it (but she'll say yes for sure!)
Happy dance,
Allison
-
by Old Toad,May 17, 2015 10:52 AM in response to Allison Sheridan
Old Toad
May 17, 2015 10:52 AM
in response to Allison Sheridan
Level 10 (140,881 points)
Photos for MacThe scripts will also run from albums.



