I am trying to write a Vb script that will take the tags (keywords) from a file and copy them into a back-up of the file in a different. directory
I have gathered together the keywords in a variable and the name of the file I want to copy to another variable.
The problem comes when I add the instruction to do the actual copy
ClickData.Func.Command.AddLine("SetAttr META newfilename ""tags:" & tagString & """")
newfilename is the name and path of the file I want to write the tags to, and tagString contains the keywords I want to write. They are filled with the correct information
It does not work. I suspect perhaps that because the variable newfilename contains spaces.
Try as I might - and I have tried - I can't find where to put the quote marks to make the command work.
That code will literally insert "newfilename" into the command. If you want to insert the contents of the variable newfilename then you have to do the same thing you're doing with the tagString variable:
First of all congratulations on the new look Resource Centre - a first rate job.
Leo - I see where I have gone wrong with the syntax here, but the problem is that even when I correct it the script does not work. It fails to write the keywords to the new file.
The first suspect,of course, is that I somehow constructed the path to the new file wrongly. I took that out of the equation by copying the file to the top of a drive. It still does not work even though your debug code seems to indicate it should
Function OnClick(ByRef clickData)
If clickData.func.sourcetab.selected_files.count = 0 Then
Msgbox "Nothing is selected",1, "NO FILE SELECTED"
'Unload.Me
End If
'Get the filenames of the selected files and construct the filename of the image to copy the keywords to
ClipString = ""
For Each SelectedItem In ClickData.Func.sourcetab.Selected
ClipString = SelectedItem.name_stem
exto = SelectedItem.ext
pathbo = selectedItem.path & "\" & ClipString & exto
oldpath = SelectedItem.path & "\"
'newfilename = "E:\Imaging\Working Images\Masks\" & clipstring & ".psd"
newfilename = "D:\" & clipstring & ".psd"
Next
'Now get the tags in the source image into a variable
Dim q
Set q = clickData.func.sourcetab.selected_files(0)
For Each tag In q.metadata.tags
If (tagString <> "") Then
tagString = tagString & "; "
tagString = tagString & tag
Else
tagString = tag
End If
Next
DOpus.Output "SetAttr META """ & newfilename & """ ""tags:" & tagString & """"
'Now create the Opus command to copy the tags to the image
cmdline = "SetAttr META """ & newfilename & """ ""tags:" & tagString & """"
clickData.func.command.RunCommand(cmdline)
End Function
The output from your debug code gives me:
SetAttr META "D:\St Lukes 1970.psd" "tags:testpic;church"
Have you any idea why this might not work. I did wonder if it was in some way related to a problem I reported last week about problems I am having with keywords applied in Dopus not appearing in Photoshop CC 2017. (In fact that is the reason for t he script, so that I can restore the keywords from a backup file.) I can't see how, but you never know.
No, Leo. The command does not insert the tags into the file when I run it from a button. I am not sure I understand the second part of your reply. But I can change to tags on the file using the Opus metadata panel quite successfully.
If you see my post on Tags not seen in Photoshop 2017 in the forum you will see the more serious side of the problem I am having