can someone point me in the right direction if i need this
exiftool -tagsfromfile XYZ.xmp -all:all XYZ.jpg
to work for hundreds of jpgs? so i have a folgeder with houndreds of jpegs and xmps with the same name but different file ending (xmp and jpeg). what would be the elegant way to go through all of them and replace XYZ with the actual filename?
i want / need to do this in a shell on osx.
do in need something like a for loop? or is there any direct way in the shell?
Thank you so much in advance!!
CodePudding user response:
Your command will be
exiftool -r --ext xmp -tagsfromfile %d%f.xmp -all:all /path/to/files/
See Metadata Sidecar Files example #15.
The -r
(-recurse
) option allows recursion into subdirectories. Remove it if recursion is not desired.
The -ext
(-extension
) option is used to prevent the copying from the XMP files back onto themselves.
The %d
variable is the directory of the file currently being processed. The %f
variable is the base filename without the extension of that file. Then xmp
is used as the extension. The result creates a file path to a corresponding XMP file in the same directory for every image file found. This will work for any writable file found (see FAQ #16).
This command creates backup files. Add -overwrite_original
to suppress the creation of backup files.
You do not want to loop exiftool as shown in the other answers. Exiftool's biggest performance hit is the startup time and looping it will increase the processing time. This is Exiftool Common Mistake #3.
CodePudding user response:
solved it by doing this:
#!/bin/bash
FILES="$1/*.jpg"
for f in $FILES; do
if [ -f "$f" ]; then
echo "Processing $f file..."
#cat "$f"
FILENAME="${f%%.*}"
echo $FILENAME
# exiftool -tagsfromfile "$FILENAME".xmp -all:all "$FILENAME".jpg
exiftool -overwrite_original_in_place -ext jpg -tagsFromFile "$FILENAME".xmp -@ xmp2exif.args -@ xmp2iptc.args '-all:all' '-FileCreateDate<XMP-photoshop:DateCreated' '-FileModifyDate<XMP-photoshop:DateCreated' "$FILENAME".jpg
else
echo "Warning: Some problem with \"$f\""
fi
done
CodePudding user response:
An elegant and easy way, IMHO, is to use GNU Parallel to do them all in parallel:
parallel --dry-run exiftool -tagsfromfile {.}.xmp -all:all {} ::: *.jpg
If that looks correct, remove --dry-run
and run again to do it for real.
{}
just means "the current file"
{.}
just means "the current file without its extension"
:::
is just a separator followed by the names of the files you want GNU Parallel to process
You can install GNU Parallel on macOS with homebrew:
brew install parallel