Last line is terminated by a linefeed

Started by DaveF, January 13, 2024, 04:21:34 AM

Previous topic - Next topic

DaveF

Quote from: Phil Harvey on October 17, 2021, 10:42:05 AMthat the last line is terminated by a linefeed.

Hi
Why does ExifTool need to do that?

It means a substr command needs to be run on it to remove the linefeed/return codes to pass it into programs (even Exiftool itself). (I'm using it within AutoHotKey scripting language)

Phil Harvey

Quote from: DaveF on January 13, 2024, 04:21:34 AMWhy does ExifTool need to do that?

You really want me to read through the entire old thread to figure out what you are talking about?

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

DaveF

#2
I'm unsure.
I thought maybe just reading your original reply would be enough of a reminder. I'm unsure what else I'm meant to provide - it would just be a repeat of that thread's first comment.

I'd like to know why it's necessary for exiftool to add a return, and for it to not do it if it isn't necessary. I've never come across another program that does that.

Edit:
It's not actually the adding of the line feed that's the true problem, but exiftool seemingly not being able to cope with it when adding exifdata.
My Autohotkey routine:

runwait %comspec% /c exiftool -T -DateTimeOriginal "%FileName%" |clip
xx := substr(clipboard,1,19) 
runwait <ffmpeg command which unfortunately removes exif data>
runwait %comspec% /k exiftool -overwrite_original -DateTimeOriginal="%xx%" -fileModifydate="%xx%" "%dir%\%FileName%.jpg"

The second exiftool command returns "No file specified" if the substr command isn't performed & the clipboard value is past directly to it.

Phil Harvey

OK.  So you're talking about the newline added to the end of the line when -p is used with an argument string.  It is done this way because 99.9% people using this option would want the trailing newline.  (How many commands do you know that give console output and no trailing newline?)

However, you can avoid the trailing newline by specifying an input file name rather than a string on the command line, just be sure the input file doesn't end in a newline.

- 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 an example, without the trailing line feed, using dir would end up like this

Y:\!temp\x\y\zz>dir
 Volume in drive Y is DrivePool
 Volume Serial Number is 3881-4F27

 Directory of Y:\!temp\x\y\zz

2024-01-11  03:41 PM    <DIR>          .
2024-01-11  03:41 PM    <DIR>          ..
2024-01-11  12:01 PM            17,526 digiKamLocationShownRegion.jpg
2024-01-11  11:56 AM            35,710 LocationShownRegionExample.jpg
2024-01-11  03:30 PM            42,366 zz.zip
               3 File(s)         95,602 bytes
               2 Dir(s)  8,319,382,986,752 bytes freeY:\!temp\x\y\zz>

Without the line feed, the command line prompt would be directly attached to the last bit of output, in this case the word "free".

Technically, this has been edited to make the result more clear, as normally dir adds two line feeds to the end
"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