What's up?
$ exiftool -r -q -q -printFormat '${FileName#}' -if '$Track1:MediaDuration# < 300' . | xargs rm
rm: cannot remove '99633372.mp4'$'\r': No such file or directory
I can, of course, strip the newline, but I'm wondering if I can tell ExifTool to choose a different delimiter like a null char?
I also know I can delete files without piping to rm, but I think I prefer to pipe to rm than edit the System:Directory tag or something like that..
Thanks!
Off hand I can't think of anything, but two things might help. First, according to this xargs man page (https://man7.org/linux/man-pages/man1/xargs.1.html), "xargs reads items from the standard input, delimited by blanks ... or newlines". And this ServerFault answer (https://serverfault.com/a/129209) gives the -d option as a way to define a custom delimiter.
One thing that pops out about your command, though, is that you are passing the filename, but you are using the -r (-recurse) option (https://exiftool.org/exiftool_pod.html#r-.--recurse), so any file in a subdirectory will have the name passed but not the directory, which would lead to a file not found error with rm.
It is safer to use ExifTool to move the offending files to a trash directory, then delete them later. Passing the output of ExifTool to rm directly seems a bit dangerous.
- Phil
Quote from: Phil Harvey on March 31, 2023, 01:48:06 PMPassing the output of ExifTool to rm directly seems a bit dangerous.
That made me remember what you said here (https://github.com/exiftool/exiftool/issues/160#issuecomment-1293946184) where exiftool calculates an approximate duration. That might lead to problems with files that have incorrect header data.
StarGeek - ahhhh...good catch regarding -r, that's embarrassing. Oh well, good that you guys are around to catch these things :)
Phil - you're right, it's not my best thinking, seeing as I don't write perfect code (like combining printing FileName with -r), it seems high risk to delete like that, leaves no room for errors, I will drop the rm.
Thanks