BASH: Help with formatting Output from a script
When annotating jpegs, whether newly-downloaded or on their way to being backed up to CDs/DVDs, I like to use the same 7 IPTC tags, and also on occasion Keywords and Supplemental Categories. Here's a list of the six:
Here's the script I have: Code:
#!/bin/bash The kind of Output I'm trying to avoid seeing (and having to edit in advance of processing with another script) looks lie this: Code:
bh_07498_015.jpg: Has Keywordsbh_07710_007.jpg: Has Keywordsbh_07710_009.jpg: ...and also the more-than-occasional ones of these: Code:
1608.jpg: Fixture Id Tag Location Tag I hope this provides enough information. Looking forward to considered replies. BZT |
Same story as always, show us what you have tried and where you are getting stuck?
This seems to have been a mammoth task, but I do not seem to be seeing a lot of your input, but mainly questions. Yes it is a question site but I believe the idea is to learn. You have also been shown time and again that arrays will probably help if you are storing multiple values for the same file (ie jpg). As far as case statements go, again show us your ideas and we can help or amend where you may make a mistake. |
Well ... a long script, a long text ...
but, sorry ... I didn't get it. You wrote a script, don't like the output, so you want a second script to correct the output of the first one? Wouldn't it be better to do things right right of the beginning? I don't understand, what are your desired results? What are undesired results? What further processing is intended (if there is any)? What's wrong with Quote:
What's wrong with Quote:
Let's talk about the basics. As far as I see, you produce a 10-value-array, consisting of "exists/exists not", associated to a filename. Quote:
A much nicer representation would be: Quote:
|
Quote:
Quote:
Code:
#for file in $*.jpg; do I commented out the for/do/done to see if it would work on one specific file. Rather than write that filename to its own ASCII text file, I thought to set it to the variable file. I suppose it's not kosher to have so many if/then/fi's inside a case/esac loop, but I've yet to puzzle out where else to put them. At any rate, rewriting it this way has given me some ideas on how to make the original script work the way I want it, in terms of "dumped" output. BZT |
SilversleevesX, if all you want is a trailing newline after each tag list, your first script was completely okay. The only thing missing was:
Code:
fi I don't see how a case structure could be useful for you. You have ten if-then-clauses and each has to be processed. "case" is useful if you have ten if-then-clauses but only one "case" has to be processed. In case we talk about tighten your code, think about this pseudocode: Code:
for file in $(ls *.jpg); There a two nested for-loops. The outer one goes through all your files listed by "ls". The inner one goes through your ten if-then clauses, reducing your code. |
All times are GMT -5. The time now is 05:32 AM. |