Set owner:group of new directories and files

Started by schultzter, August 05, 2014, 04:45:03 PM

Previous topic - Next topic

schultzter

I've searched the forums and googled but haven't found anything.

I'm using ExifTool to manage the photos coming off my family member's phones onto the NAS. I add an Artist tag and sort the images into a common gallery by year and date. Here's the command I use:

/opt/Image-ExifTool-9.67/exiftool -recurse -progress -preserve -overwrite_original -d /media/Galleries/%Y/%Y-%m-%d/%%f%%+c.%%e "-Author=${AUTHOR}" "-FileName<CreateDate" /backup/${SOURCE}/DCIM

I'm running that command directly on the NAS so it's all local rather than back-and-forth over the network. But that means the command is run as root and the new directories and moved files all belong to root:root. I would like them to belong to media:users (media user and the users group).

So is there a way to either

  • Get a list of all the directories created by the last run of ExifTool so I can run chown on them afterwards?
  • Or tell ExifTool to create those directories and files with appropriate user:group?
I can't just run ExifTool as the media user since it isn't a real user (it's just the owner of the media share) and besides, I need permission to delete the old files from /backup share/directories.

Thanks,

Hayo Baan

Solution 1 can easily be implemented with a find command. Something like find folder -user root -exec chown media:users {} \; will change the owner of all files currently owned by root in folder to media:users.

Hope this helps,
Hayo
Hayo Baan – Photography
Web: www.hayobaan.nl

schultzter

Quote from: Hayo Baan on August 05, 2014, 05:21:02 PM
Solution 1 can easily be implemented with a find command

Thanks. Perhaps I don't know the find command well enough, I'll add that to my script.