Set owner:group of new files

Started by tylla, February 06, 2017, 08:19:05 AM

Previous topic - Next topic

tylla

I am requesting a feature, namely to implement and change the FileUserID, FileGroupID to be writable the same way as FilePermissions are.

This question may seem as a duplicate as the thread at https://exiftool.org/forum/index.php/topic,5976.0.html is about the same issue, only I didn't want to resurrect a really old thread, and OTOH I would like to post this as a feature request. The rationale is below:

The solution suggested on the linked thread - use find to search for files with given attributes and change them accordingly - might work for certain scenarios, but when there are huge piles of files, the cost/gain ratio is really bad, I mean find has to search through lots of files only to change the attributes of a few.
Not to mention the drawback that the file ownership only gets changed after the whole exiftool operation is finished (my script is using the -@ ARGFILE to pass the files to be processed, as the previous operation - that generates the file list - is done in one pass as well).

As for technical information (not that it would matter, as the docs state that FileUserID, FileGroupID is not writable.)
My system is Linux (Debian Jessie).
I use exiftool ver. 9.74
The command line is something along the lines:
exiftool -overwrite_original '-FileUserID<1007' ./20050802_171954.jpg -v3
The output (as one would expect):
Warning: No writable tags set from ./20050802_171954.jpg
Nothing changed in ./20050802_171954.jpg
    0 image files updated
    1 image files unchanged

while I would whish/expect one file changed.

Phil Harvey

#1
To do this properly I would need to be able to convert a user/group name to an ID number.  Do you know how to do this?  Edit: Answered my own question: getpwnam does this

Also, you command should use an "=" to assign the value (not "<" which is for copying the value of another 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 ($).

tylla

Quote from: Phil Harvey on February 06, 2017, 08:27:46 AM
To do this properly I would need to be able to convert a user/group name to an ID number.  Do you know how to do this?  Edit: Answered my own question: getpwnam does this

Well, using user/group names is the best solution but even the ID would be welcomed.
Actually at first I didn't even think about user/group names, my thought was like: if it's called FileUserID than give it an ID. That's why the 1007 value in the example.

Quote
Also, you command should use an "=" to assign the value (not "<" which is for copying the value of another tag).
Ooops, my bad. Got used with copying tag values back and forth. :)
But luckily in this case it didn't matter.

Anyway, thanks for considering this.

Oh, and the best for last: exiftool rocks!!! :))

Phil Harvey

Quote from: tylla on February 06, 2017, 11:15:31 AM
Well, using user/group names is the best solution but even the ID would be welcomed.
Actually at first I didn't even think about user/group names, my thought was like: if it's called FileUserID than give it an ID. That's why the 1007 value in the example.

Right.  It is an ID number if -n is specified (or a "#" after the tag name), or a name otherwise.  But the tag name doesn't change.

I have figured out how to write by ID and name, and tested it out on my Mac, and both these commands work for me:

exiftool -fileuserid=phil -filegroupid=staff a.jpg

exiftool -fileuserid#=501 -filegroupid#=20 a.jpg

and as an added bonus, I have included logic to allow this too:

exiftool -fileuserid=501 -filegroupid=20 a.jpg

This feature will appear in ExifTool 10.42.  Note that you need superuser privileges to set the user/group ID's of files you don't own.

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

tylla

Quote from: Phil Harvey on February 06, 2017, 12:04:02 PM
and as an added bonus, I have included logic to allow this too:

exiftool -fileuserid=501 -filegroupid=20 a.jpg

This feature will appear in ExifTool 10.42.  Note that you need superuser privileges to set the user/group ID's of files you don't own.

Wow, that's what I call swift action!!! :)

BTW I thought about the extra logic as well, but I didn't want to add to the burden.

Thank you very much!