Get File Name after changing it

Started by theprof, October 30, 2024, 02:02:50 PM

Previous topic - Next topic

theprof

I have some sample code below which changes the file name based on the file modify name. I pass the "SOURCE_FILE" from BASH into EXIF and it renames the file. How do I get back the NEW file name into a variable in BASH? Is there any EXIFTOOL option to return the new name?

exiftool -P -F -q -q -overwrite_original_in_place -SourceFile -api LargeFileSupport \
-FileOrder CreateDate -FileOrder -FileSize -FileOrder FileModifyDate \
-api QuickTimeUTC -if '$MimeType=~/^(video|image)\//i' \
-d "%Y-%m-%d %H-%M-%S %%.2nc.%%le" \
'-AllDates<FileModifyDate#' "$SOURCE_FILE"


Phil Harvey

Something like this may do it:

newname=`exiftool -P -F -overwrite_original_in_place -SourceFile -api LargeFileSupport \
-FileOrder CreateDate -FileOrder -FileSize -FileOrder FileModifyDate \
-api QuickTimeUTC -if '$MimeType=~/^(video|image)\//i' \
-d "%Y-%m-%d %H-%M-%S %%.2nc.%%le" \
'-AllDates<FileModifyDate#' "$SOURCE_FILE" \
-v | grep -e '-->' | sed "s/.*--> '//;s/'//"`

But I don't have time to test this out to see if it actually works.

- 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 ($).

StarGeek

As Phil's command shows, it would require the removal of -q -q. You can't use the -q (quiet) option and still get a response from exiftool.

A couple of additional notes, as of version 12.88, the -api LargeFileSupport option is on by default, so it isn't needed on the command line.

I'm not sure why "-SourceFile" is there. There isn't a tag or option with that name.

The command as shown doesn't rename your file.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype