Another problem script -- "unexpected token" error
I have run bash -x and -v debug lines on this one, but it still offers up no clue.
In fact, bash -x (nameofscript) returns only the echos to introduce the script, runs them, then at the first 'if' test, stops and repeats the error. Here's the code: Code:
#!/bin/bash Just so folks know ahead of time, the two lines Code:
title0=$(exiv2 -g Xmp.dc.title -Pv $file) I look forward to suggestions. In the meantime, I have other means by which to achieve the tasks this script does. BZT |
Wrong number quotes:
Code:
if [ -n "$spinstr" ]; then |
Thanks again grail
I appreciate your suggestion about the number of ifs, and it calls to mind one thought I had when writing the script this was derived from. I really wanted it to be able to log what Exiv2 found and copy the tag value to the corresponding field simultaneously or, barring that, in so quick succession as to make no difference. Looked at another way, if the copying was done within the same loop as the logging, that would definitely reduce the number of if/fi tests, at first glance by half. It will certainly take some work, but I also certainly see the sense in rewriting the script with that (dropping the number of if tests, particularly since so many of them repeat themselves) as a goal.
Bye-bye "ricoh" function. *G* Thanks again. BZT |
I agree with other comments I have seen on your posts though ... how do you go about having data delimited by a newline and a backspace? (very curious)
|
Also something like the following format may help reduce what you have:
Code:
declare -a photoshop_arr Also the use of global variables and constant setting and changing to new variables seems a bit over the top, eg: Code:
cate=$(exiv2 -g Xmp.photoshop.Category -Pv $file) Something else that confuses me is: Code:
for riall;do exiv2 -kM"add Iptc.Application2.Keywords String $riall" $file ;((w++)); done Code:
if [ -n "$pkey" ]; then |
Trying a little "reduction"
I went back to the script this one was derived from, and tried to eliminate the redundant if/then/fi's and unnecessary variable value passing. I think, at one point, what I had in mind for both scripts was a "pause" to let the user decide whether or not they actually wanted to copy what data was found to the file in the other metadata block (area? zone?). But that would have meant another 'read,' and as there was already a 'while read' loop running, the first one was sure to 'run over' the second one, so I didn't pursue it.
The 'for' loops for adding Keywords and Supplemental Categories were still glitchy (and now I see why). In this script they've been removed altogether. I'm including the "trimmed" code of the other script here for comments and suggestions. Code:
echo "Copying..." I appreciate all the help and suggestions, and if I should run into a problem with making the script in my OP less redundant, I'll be sure to try a few of them. Good times, all. BZT |
Quote:
I think these edited ones should work, however. Code:
#for XMP to IPTC I'm also looking at the array suggestion as a way to speed up an older script that checks 7 or 8 IPTC fields and writes the names of the ones without any string length to a text file. With this I might be running before I dare walk. But finding a means of slimming down that other script has been a goal of mine for a couple of years now. But back to the topic of these scripts. As they are written now, have I made the changes necessary to get the above functions to work, and not just look like they're doing so with the "friendly but meaningless" echos to stdout ? BZT |
Well I am not sure as I do not know where 'keys' or 'cats' is coming from?
|
You're in good company, grail. For now, anyway. *S*
Quote:
In other words, and without the extraneous commentary, if you don't know where 'keys' and 'cats' are coming from, you're not alone. At this point, neither do the subshells executing the commands in the scripts. BZT |
All times are GMT -5. The time now is 06:39 PM. |