Batch Rename AppleScript problem in Capture One 21
Hi,
I have the following rename script, it appears to work well without errors but nothing changes in the capture one file name.
Can you give me some help?
tell application "Capture One 21 Beta"
set the_images to (selected variants)
repeat with thisImage in the_images
set EAN to name of thisImage
set REFERENCIA to do shell script ("python /Users/vicape92/Downloads/OneDrive_1_21-4-2021/eantoref.py " & EAN)
tell batch rename settings of current document
set token format to "[Nombre del trabajo]-[Contador de 4 dígitos]"
set job name to REFERENCIA
end tell
batch rename variants thisImage
end repeat
end tell

-
It looks like the error (or lack of an error) is because you're doing a batch rename on a single image. Try putting your image into a list:
batch rename variants [thisImage]
Alternatively you could try storing the reference in another metadata field (maybe Job Identifier) and doing a single batch rename operation.
0 -
1) You shouldn't be discussing anything to do with a Capture One Beta product in this forum
2) It seems you are developing a new script, and you are somewhat new to this work. Using a Beta version of of anything for this purpose is inadvisable. Use any non-beta version of Capture One 21 or 20. e.g. Capture One 21.1 (v14.1.0.220)
3) Your script is not running without errors. In your screen grab on line 3 of the bottom window there is an error that is likely the root cause of your problems. You should pay careful attention to the errors and responses in this window.
4)The first error is that your "Rename EAN REF" script is written so that it is telling Capture One 21 to execute the do shell script command. But do shell script is not one of the commands in Capture One 21's dictionary. It doesn't know how to do that.
5) The command do shell script is in the Scripting Additions dictionary. I think that tell current application to do shell script or tell me to do shell script or tell application "Scripting Additions" to do shell script may work.
6) The job name property of batch rename settings expects a string. I suspect that you cannot use a reference to a script and expect the script to run. In any case the job name property does not become the name of the new file.
7)You will be more successful and less frustrated if you start using Script Debugger.
0 -
And some more:
8) You start by using a variable named the_images, but then you are filling it with a list of variants. This is logically confusing and may give you trouble in the long run.
9) Capture One associates the file name with the Image, not the variant, You may have two or more variants in the list with the same parent image. Your script would result in renaming sucj Image parents two or more times. Batch rename might handle that correctly, but only if you give it the entire list of variants at once - which you don't.
10) You start by decelairing a list of variants and then iterating through that list 1 variant at a time. Then for each variant you end up using Batch rename (which is used to handling a list of variants) to rename the parent image of one variant. Batch rename requires a list of variants, and you are not supplying a list.
11) You could more easily accomplish your purpose by setting the name of the parent image of each variant and stop using batch rename at all. And then keep a list of all the ID's of parent images already changed, and not rename a parent image if it is on the list.
0 -
Here is how I would write it. I have tested it as far as I can without having your script.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set imageIDList to {}
tell application "Capture One 21"
set the_variants to (selected variants)
repeat with theVariant in the_variants
set the_Parent to (a reference to theVariant's parent image)
set parentID to 0 + (the_Parent's id) -- convert to integer
if imageIDList does not contain parentID then
set imageIDList to imageIDList & parentID
set EAN to the_Parent's name
## copy EAN & "" to REFERENCIA -- for testing purposes
tell me to set REFERENCIA to do shell script ("python /Users/vicape92/Downloads/OneDrive_1_21-4-2021/eantoref.py " & EAN)
copy REFERENCIA to the_Parent's name
end if
end repeat
end tell0
投稿コメントは受け付けていません。
コメント
4件のコメント