Need to exclude hidden files in directory

Started by Gary, November 15, 2015, 02:59:20 PM

Previous topic - Next topic

Gary

When executing an exiftool command, I'm picking up hidden files with the same suffix. ie. "._filename.CR2" These are generating errors.
I think these or left over from when the drive was connected to my mac computer. Is there a way to tell ExifTool to ignore hidden files?

I don't want to erase them just yet, since it could upset the Mac when I access the drive.

Phil Harvey

You could avoid these files like this if you want:

exiftool -if '$filename !~ /^\./' ...

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

ryerman

I can't decipher the -if argument, but my testing seems to show that is has nothing to do with the hidden attribute of a file.

Is there some way for Exiftool to identify files with any particular attribute (eg. hidden, system, archive etc.)?
Windows 10 Home 64 bit, Exiftool v12.61

Phil Harvey

On Mac, any file with a name starting with a dot is hidden.  On Windows, you could do this:

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

ryerman

Thanks.
I'd never seen File Attributes shown in the System section, like File Permissions or File Size.
I therefore assumed they were unavailable.
Good to know they are.
Windows 10 Home 64 bit, Exiftool v12.61

Phil Harvey

There are a number of cool, useful and not-very-well-known features like this in the Extra Tags.

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

Gary

Thanks, Phil.
I'm using a 4TB MyBook. Sometimes I connect it to my Mac Laptop and sometimes to my Windows 10 Surface Pro 3.
This is necessary as I'm migrating off the Apple platform before they make the desktops just big iPhones on a stand (smile).
They dropped Aperture and substituted a second rate product, Photo, so I really don't have a choice but to change platforms. (I don't like subscription-ware alternative, Adobe Lightroom).
In the meantime, I'm finding that running the two systems on one drive seems to result in "hidden" files being "dropped" in my directories.
Not sure whether these are needed by one of the O/S's, so best not to touch until I'm sure. With your tip, I can now avoid the issue and get some work done.

Phil Harvey

The "._" files created by OS X on non-Mac volumes store the resource fork for the file.  These are generally used to store transient information, and may be deleted without causing problems.

I agree about subscription products.  I won't use them.

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

Gary

#8
The suggested method of filtering out "Hidden" files still causes ExifTool to generate errors.
If I add any command to the command shown, ExifTool executes the command only on the filtered files and still generates an error message.
Not sure what is the solution.

I created a batch file onto which I dragged and dropped a test directory. The batch file that has the form of:
exiftool -if "$fileattributes !~ /Hidden/" -r %1 > "FULL_PATH_AND_NAME_OF_LOG_FILE"

Generates:
======== DIRECTORY_NAME_BEING_PROCESSED/._2009-07-18 at 14-22-53 (MDT).CR2
ExifTool Version Number         : 10.05
File Name                                : ._2009-07-18 at 14-22-53 (MDT).CR2
Directory                                 : DIRECTORY_NAME_BEING_PROCESSED
File Size                                  : 4.0 kB
File Modification Date/Time     : 2015:10:23 13:54:26-06:00
File Access Date/Time             : 2015:11:22 09:47:31-07:00
File Creation Date/Time          : 2015:11:22 09:47:31-07:00
File Permissions                      : rw-rw-rw-
Error                                       : File format error

Phil Harvey

Hi Gary,

The output you show indicates that the file was processed (contrary to what you described).  But you should use the first command I posted to filter out files beginning with '.'.  I don't know if the Hidden property is set on these files (what is the output of "exiftool -fileattributes FILE"?)

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

Gary

Phil;

I actually did use what you'd posted, but was trying to illustrate what resulted and didn't do a good job.

Here is the result of the command you asked me to run. Notice the unique separator after "Hidden". Odd.

C:\Users\Gary Gauthier>exiftool -fileattributes "G:\Raw Images\Canon EOS 30D\2009\2009-07-18 (Grizzly Day Use Area, Kananaskis Country, AB, CA)\._2009-07-18 at 14-22-53 (MDT).CR2"
File Attributes                 : Regular; (none); Hidden, Archive

Here is what happens when I try to use it:

C:\Users\Gary Gauthier>exiftool -if "$fileattributes !~ /Hidden/" -"DateTimeOriginal>CreateDate" "G:\Raw Images\Canon EOS 30D\2009\2009-07-18 (Grizzly Day Use Area, Kananaskis Country, AB, CA)\._2009-07-18 at 14-22-53 (MDT).CR2
Error: File format error - G:/Raw Images/Canon EOS 30D/2009/2009-07-18 (Grizzly Day Use Area, Kananaskis Country, AB, CA)/._2009-07-18 at 14-22-53 (MDT).CR2
    0 image files updated
    1 files weren't updated due to errors

Yes, it is not updating the file that is hidden, but it is because it still saw it and generated an error.


Phil Harvey

OK, I don't understand.  I guess I'll have to try this on Windows when I get a chance, because this is what happens on a Mac (checking the filename instead of fileattributes):

> exiftool -if '$filename !~ /^\./' -"DateTimeOriginal>CreateDate" ._test.cr2
    1 files failed condition


I would have expected the behaviour to be the same in Windows, but apparently not.  Somehow the result of your -if evaluation is true, even though looks like it shouldn't be, because ExifTool is attempting to update the file.

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

Gary

I'd love to know what you find out, Phil.
In the meantime, I'll just do an explicit recursive erase of hidden files using "del %1 /A:H /S /Q"

Is the comma, rather than semicolon, in "Regular; (none); Hidden, Archive" significant or is it just a formatting thing in the Exiftool output?
Could Exiftool have seen "Hidden, Archive" instead of just "Hidden" and thought it was not a match with "Hidden"?

Phil Harvey

#13
Quote from: Gary on November 22, 2015, 09:35:32 PM
Is the comma, rather than semicolon, in "Regular; (none); Hidden, Archive" significant or is it just a formatting thing in the Exiftool output?
Could Exiftool have seen "Hidden, Archive" instead of just "Hidden" and thought it was not a match with "Hidden"?

No.  /Hidden/ looks for the substring "Hidden" anywhere in the string.  Did you make it a "List"-type tag?

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

Gary

No. I basically ran the command you ask me to run on a typical hidden .CR2, then cut and pasted the result.
I did set the Windows File Explorer to make hidden files visible in File Explorer, so I could see the target file to drag it into the command-line.
However; this does not typically change the actual file attribute, and the output of ExifTool seems to bear that out.
Curious...