News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Problem with hash?

Started by tm, June 02, 2012, 05:16:04 AM

Previous topic - Next topic

tm

Hi to all,

so again I'm trying to improve and fasten our workflow. Todays problem is that we need to tag a code into keywords of the images.

The code needs to be something like this:

#M675;#54F0

my Code is:

set thefile to choose file
set thefile_unquoted to POSIX path of thefile
set thefile to quoted form of thefile_unquoted
set farbcode to "#M675;#54F0"
do shell script "exiftool -overwrite_original -Keywords=" & farbcode & " " & thefile


the answer of the editor:

tell application "AppleScript Editor"
   choose file
      --> alias "100GB_system:Users:tm:Desktop:Z21768.tif"
end tell
tell current application
   do shell script "exiftool -overwrite_original -Keywords=#M675;#54F0 '/Users/tm/Desktop/Z21768.tif'"
      --> error "No file specified" number 1
Ergebnis:
error "No file specified" number 1


So it seems to be a problem with the hashes, is there any way to get this special tag into the keywords?

Thanks a lot.


Phil Harvey

You must quote your keywords the same way that you quote your file name:

set theKeyword to quoted form of farbcode

do shell script "exiftool -overwrite_original -Keywords=" & theKeyword & " " & thefile


The problem was actually the semicolon, not the hash marks.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

tm

Ah, I see.

so I needed the quoted form to create a string with no matter whats between the quotation marks, right?

Now it tags the file, but the new problem are the quotation marks, the tag now looks like this:

"#M675;#54F0"

how do I get rid of the quotation marks in the tag?

Thank you for the fast answer, and is it really half past 6 in the morning where you are? what about a nice cup of tea or coffee?

sebastian.

Phil Harvey

#3
Hi Sebastian,

Yup, really 06:30am here, on a rainy Saturday morning. :)

You only need to quote the keyword if it contains special characters.

But somehow it seems that it is getting double quoted.  I haven't done much AppleScript myself.  Does the line:

set farbcode to "#M675;#54F0"

set farbcode to #M675;#54F0 or "#M675;#54F0" ?

If the latter, then that is the problem.

- Phil

Edit: Since I had nothing better to do, I fired up the AppleSript Editor and gave this a try.  This script worked for me to add the keyword without quotes:

set test to "#M675;#54F0"
set theKeyword to quoted form of test
do shell script "exiftool /Users/phil/Desktop/a.jpg -keywords=" & theKeyword


> exiftool ~/Desktop/a.jpg -keywords
Keywords                        : #M675;#54F0
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

tm

:) here it is nearly 1pm but it's cloudy, too. not rainy by now...

the problem is that I get the tag out of a txt file with a shell script:
->   set farbcode to do shell script "awk -F _ '/" & artikelnummer & "/ {print $2}' " & data_file1
       
the variable farbcode is filled by the shellscript without quotation marks (answer is #M675;#54F0), but then we have the problem with the semicolon, as you said...

I can't get rid of the semicolon between the codes, it is a guideline by our clients...


Phil Harvey

Well, somehow your farbcode contains something different than my test, otherwise it would work for you.

Quoting command-line arguments can sometimes be tricky, but you should be able to figure it out.  You could try escaping the semicolon with \;

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

tm

hey again,

today I got feedback from our client, they coudn't work with the testfile ...
I sent them a testfile with the latest tagging, in Adobe Bridge it was mention with quotes, in exiftool without, but somehow their workflow reads the quotes and so it doesn't work.

I'll ask someone for modifications in the shellscript and also ask the client whether we could use another delimiter between the codes (there are differences from file to file, sometimes 1 code, sometimes more...)

greetings and thanks again.

Phil Harvey

If ExifTool shows it without quotes, then the quotes aren't there.

My guess is that the other applications are adding quotes for display.

I noticed that AppleScript adds quotes to output strings in its console window for example.

You should try some variations without a semicolon... you may still have some applications that show quotes.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

tm

yeah, I'll check that out.

In another script I use the same structure and another source-file (i.e. O26244_S11NBAY379TRAAD) and the S11NBAY379TRAAD is tagged into the picture (without quoted form or sth like that) here it is shown without quotes in Bridge or Photoshop.

But that was just to talk about it.

I got feedback from the client, who said that the don't need the semicolon, the delimiter just has to be always the same, so, do you know a character that's not recognized by exiftool (without letters and numbers) that i could use as a delimiter between the codes?

Thanks and best wishes from a cloudy but dry monday afternoon.
Sebastian.


Phil Harvey

Hi Sebastian,

ExifTool allows any characters (or any binary data for that matter, depending on your character set settings).

The limitation is only in the shell scripting.

Maybe something like a slash (/) or dash (-) would be simplest for you.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

tm

I tried the dash and it worked properly. So I changed the sourcefile.
Thanks a lot.