For some reason, copying files from my phone over the MTP fuse interface sometimes results in corrupt files, missing their last few bytes. I want to remove each file on successful transfer, but not remove them if there was a problem. The
mv command doesn't have a
--verify option. I could write a short script which copies, checks, and removes, but I'm wondering if there's a more elegant existing command which can handle this?
As a bonus, it'd be nice to specify both checksum match and success from an external verification command, in this case
jpeginfo -c. I think the short reads are random occurrences, but I haven't really tested that the bad file isn't actually cached that way (or otherwise would be read incorrectly in the same way twice). So, something like
mv --verify --verifywith='jpeginfo -c' would be ideal (where
jpeginfo -c is a command that tests JPEG files for correctness and which I know will return an error on these particular truncated files).