I have a mounted directory to access some images.
When opening an image for the first time with open /mounted_dir/foo.jpg
it opens the image in preview.
When repeating the same command it gives the error:
/mounted_dir/foo.jpg is damaged and can't be opened. You should move it to the Trash.
I have seen this error message on the web but only for apps, not image files. Furthermore, the file in question doesn't appear damaged, eg:
cp /mounted_dir/foo.jpg /tmp/foo.jpg
diff /mounted_dir/foo.jpg /tmp/foo.jpg #no difference
open /tmp/foo.jpg #works
open /mounted_dir/foo.jpg #same error
Is there any other way than setting preference to do this (in System Preferences > Security & Privacy: Set "Allow Applications Downloaded From" to 'Anywhere') ?
Ideally, I'd like either a open --force mode or a command line way to tell the system that the file isn't damaged, or (last resort) command line to set the System Preferences > Security & Privacy option.
Check if the com.apple.quarantine flag is set, and if so, remove it.
➜ xattr foo.pdf
com.apple.quarantine
➜ xattr -d com.apple.quarantine foo.pdf
➜ xattr foo.pdf
Alternatively, disable Gatekeeper. See here: https://boxcryptor.desk.com/customer/portal/articles/688364-why-am-i-receiving-the-error-%22filexyz-is-damaged-and-can-t-be-opened-you-should-move-it-to-the-trash-%22-under-mountain-lion-