Is it possible to have ExifTool not automatically unhide Windows hidden files?

Started by mpegleg, May 26, 2019, 10:45:07 AM

Previous topic - Next topic

mpegleg

Quote from: Phil Harvey on May 27, 2019, 07:18:21 AM
I have no idea why opening a file for rewrite should remove the hidden status in Windows.  I'll look into this when I get a chance (may be a while).

- Phil

*BUMP*

Hi Phil. Just hoping that this problem hasn't been forgotten about? Exiftool is amazing, and I'm so happy with all the uses I have put it to. It's helped me tremendously with getting my archive photo/transparency collection organized.

However, (as previously explained here) whenever I do any Exiftool operations in Windows, I often forget that I need to then go and re-hide all of my 1000s of hidden edited jpg files again.

It really is a pain, esp. as Windows 10 Explorer currently has a bad Search bug that often prevents the correct function of the Explorer Search box, and usually requires a full system restart, for just a short-term temporary fix.  (So, it's not always an easy task to find and re-hide all the previously hidden files). edit-- Seems like Microsoft has "just" released a patch for this Search bug. Eagerly installing it now. Fingers crossed!
OS: Windows 11 Pro

Phil Harvey

Sorry for the delay in getting around to this.  I can't reproduce this problem on my Windows 10 system.

I created a tmp directory with 2 identical files (a.jpg and b.jpg), then set the hidden attribute on one of them (a.jpg) from Windows Explorer.  Below is a screen capture from my cmd.exe window showing what happened.  It wouldn't let me write the hidden file when I used the -overwrite_original_in_place option.

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

mpegleg

Thanks for your answer Phil.

Yes, I also get the same results as you.

I guess what I'm really hoping for, is a way for exiftool to initially read a file's attributes (and remember them), and then after doing any operation, there would be an internal way of then restoring the file's attributes to the way they were, even when writing a new file with the overwrite_original option.

I understand that I can use batch files to accomplish this, however there are many times when I use other shell programs that then also call exiftool. Thus it really isn't always practical to use batch files.

The way I have my photos now organised is as in the following simplified example:



This works very well for me. Any Original/mediocre images that have been edited can be hidden in situ, which is very convenient, and hidden/unhidden files can be viewed with a simple click. Also, I can tell exiftool to ignore anything in the "Other" hidden subdirectory, (containing other edits, videos and general info etc.) which will also not be seen by other programs.

Thus my other external programs (like Image Resizers) will generally only process unhidden files. Thus they only see the (unhidden) files that I want them to see and hence process only these.

Unfortunately if I run exiftool with -overwrite_original set, (which is what I always use) all the hidden files will be then get unhidden, and I have to then search for them all (I use the Copyright tag to indicate which images should always be hidden).

I understand that it's not exiftool's fault that they get unhidden when writing a new file, (it's a system thing) but I was really hoping that there may be something that could be done, to reset the original Hidden Attribute? :)

All up it's not a game changer, but something that is really annoying, as I will often forget to re-hide the images after using exiftool, and then process and resize them all. Then, I'll excitedly go and show my folks some new photos, only to realize that they are seeing all of my once hidden mediocre/rubbish images.  :'(


I strongly believe that: If a file is designated as "Hidden"... Hidden it shall thus remain, for all eternity. :P
OS: Windows 11 Pro

Phil Harvey

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

ryerman

I make use of the current behaviour.
For me, it is useful to expose hidden files.
Why?
Because when playing audio files, some applications create hidden JPG files near the audio files, which I don't want.
I want to expose those hidden files when tagging my own, desirable JPG files.

I test for hidden files in my tagging script so I will deal with any change in Exiftool behaviour, but perhaps others rely on the current behaviour for other reasons.

Another example of "One man's trash is another man's treasure".  ;)
Windows 10 Home 64 bit, Exiftool v12.61

mpegleg

Quote from: ryerman on February 02, 2020, 08:55:24 AM

...perhaps others rely on the current behaviour for other reasons.

Another example of "One man's trash is another man's treasure".  ;)

Perhaps, yet it is entirely unexpected behaviour. Hidden files are generally hidden for a good reason. Especially system files, which should not normally be played around with, moved or changed. I rely on that fact, as it is the correct accepted behaviour.


https://www.lifewire.com/what-is-a-hidden-file-2625898

For the best of both worlds, perhaps it would be be great if Phil could work out a way to give one the option to either keep the files's default prior attribute status, or to explicitly unhide a file (as is currently done).

Anyway, I won't go on about it, as Phil has said that he'll look into it. I'm just glad to have discussion about the issue, as it's very important to me. It's the only issue I have with ExifTool, as it causes a lot of extra work, to constantly have to go back and re-hide any hidden files (all of my original images) that were touched by ExifTool.
OS: Windows 11 Pro

mpegleg

Ok. After some experimenting with other photo editing programs, it seems that when re-saving over the top of the same Hidden file (ie. not changing it's filename) most apps will either give an error that the file can't be written to, or they will write to another temporary file, delete the existing file, and then change it's name back to the original. Thus they exhibit the same behaviour as ExifTool in not preserving the Hidden file attribute. Grrrr.

Even so, as mentioned previously, I would still love for there to be an ExifTool option to preserve the Hidden File attribute. Here's hoping. ;)
OS: Windows 11 Pro

Phil Harvey

Unfortunately the Win32API::File module doesn't have a routine to set the file attributes, so I don't know how this could be done.  However, if it helps you can prevent ExifTool from writing hidden files or handle them separately with a command like this (as mentioned in here).

exiftool -api systemtags -if "$fileattributes !~ /Hidden/" ...

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

mpegleg

Thanks Phil. I'll see whether I can make use of that.

I'm not pretending to understand the programming side of things, but are these references at all relevant to Perl? Just thought I'd reference them in case they are relevant. I have no idea, but they look interesting...

>>>> https://docstore.mik.ua/orelly/perl4/perlnut/ch22_05.htm <<<<

https://docs.microsoft.com/en-gb/windows/win32/api/fileapi/nf-fileapi-setfileattributesa

https://docs.microsoft.com/en-gb/windows/win32/api/fileapi/nf-fileapi-setfileattributesw

http://www.java2s.com/Code/Perl/Win32/TochangetheattributesyoucancallSetAttributes.htm
OS: Windows 11 Pro

Phil Harvey

Thanks for the links, but Windows is more of a pain in the ass than you think.  Most Windows interfaces do not support wide-character file names, which is why I was using the Win32API module.  I suppose I could use Win32::File, but then I wouldn't be able to preserve the hidden attribute for any file with a special character in its name.  Also, ExifTool doesn't yet have a dependence on Win32::File, and don't want to add it just for this.

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

mpegleg

Thanks again Phil. I totally understand where you are coming from in regards to programming for Windows being a PITA. :-\

Anyway, I'm glad we had the discussion, as I needed to know if it was possible. I can live without it. Once I have my photo collection completely organised, (and it's getting close), I shouldn't have to worry too much about it, as long as I remember to keep all my files tagged internally with my own "Hidden" status tag. (Using the Copyright tag currently works for me, as long as I keep an eye that no other editing programs are messing with it). I've always got plenty of archived backups to fall back on.
OS: Windows 11 Pro