| Author |
Batch commenting images
|
|
| Tuxedo 2007-08-22, 7:23 pm |
| Can anyone advise how best to batch comment a directory full of *.jpg files?
For this I think the wrjpgcom program best serves the purpose:
wrjpgcom -c "View of my back yard" in.jpg > out.jpg
However, a copy of each image must be made with a different name because
otherwise the resulting image will be overwritten, e.g. this does not work:
wrjpgcom -c "View of my back yard" *.jpg
What is the best way to rename all images in a directory while keeping the
same files names?
| |
| Ed Morton 2007-08-22, 7:23 pm |
| Tuxedo wrote:
> Can anyone advise how best to batch comment a directory full of *.jpg files?
>
> For this I think the wrjpgcom program best serves the purpose:
>
> wrjpgcom -c "View of my back yard" in.jpg > out.jpg
>
> However, a copy of each image must be made with a different name because
> otherwise the resulting image will be overwritten, e.g. this does not work:
>
> wrjpgcom -c "View of my back yard" *.jpg
>
> What is the best way to rename all images in a directory while keeping the
> same files names?
Assume your usage of "wrjpgcom" is correct, I think this is what you want:
for file in *.jpg
do
wrjpgcom -c "View of my back yard" "$file" > tmp &&
mv tmp "$file"
done
Regards,
Ed.
| |
| Tuxedo 2007-08-22, 7:23 pm |
| [...]
>
> Assume your usage of "wrjpgcom" is correct, I think this is what you want:
My usage is not exactly correct for what I need, as in fact I need to
overwrite the previous comment (or delete and then rewrite it). I haven't
figured how that's done yet..). wrjpgcom -c simply appends a comment string.
However, the below renaming procedure does exactly what I need, thank you!
>
> for file in *.jpg
> do
> wrjpgcom -c "View of my back yard" "$file" > tmp &&
> mv tmp "$file"
> done
>
> Regards,
>
> Ed.
| |
| Tuxedo 2007-08-22, 7:23 pm |
| [..-]
> My usage is not exactly correct for what I need, as in fact I need to
> overwrite the previous comment (or delete and then rewrite it). I haven't
figured it: the -replace flag simply replaces any previous comment.
for file in *.jpg; do wrjpgcom -replace -c "View of my back yard" "$file" >
tmp && mv tmp "$file"; done
Thanks again for the batch renaming procedure!
| |
| Dave Kelly 2007-08-23, 1:21 am |
| Tuxedo wrote:
> Can anyone advise how best to batch comment a directory full of *.jpg files?
>
> For this I think the wrjpgcom program best serves the purpose:
>
> wrjpgcom -c "View of my back yard" in.jpg > out.jpg
>
> However, a copy of each image must be made with a different name because
> otherwise the resulting image will be overwritten, e.g. this does not work:
>
> wrjpgcom -c "View of my back yard" *.jpg
>
> What is the best way to rename all images in a directory while keeping the
> same files names?
#!/bin/bash
pname=$1
number=0
ONE=1
for filename in *.jpg
do
let "number += 1"
mv "$filename" "$pname-$number.jpg"
done
if [ "$number" -eq "$ONE" ] # For correct grammar.
then
echo "$number file renamed."
else
echo "$number files renamed."
fi
--
A little rum in the morning coffee. Just to clear the cobwebs, ya know.
| |
| Tuxedo 2007-08-23, 1:27 pm |
| Dave Kelly wrote:
[...]
>
> #!/bin/bash
>
> pname=$1
> number=0
> ONE=1
>
> for filename in *.jpg
> do
> let "number += 1"
> mv "$filename" "$pname-$number.jpg"
> done
>
> if [ "$number" -eq "$ONE" ] # For correct grammar.
> then
> echo "$number file renamed."
> else
> echo "$number files renamed."
> fi
>
Although I used Ed's solution, the above also goes in my collection of
examplary code - many thanks!
|
|
|
|