Score:1

how to us the chown command and mv with find command

kn flag

I have been searching around and found this question which almost solved my problem. The goal is to have a folder on Ubuntu server which other computers connect to and save files. I have two directories ('Movies' and 'TV') inside a folder called 'import'. I modified the command to work perfectly to transfer those files to my actual Plex media directory. The only thing I can't figure out is how to change the ownership of the files to the plex user. Is there a way to use the chown command before moving the files?

I don't want to mess with the import directory because someone (nobody:nogroup) could be writing to it when the chown command executes. The alternative is to apply the chown -R plex:plex command on my /mnt/nfs-plex, but then I am doing that over and over again on my files causing unnecessary hard drive activity. I included my modified version of the commands.

Movies:

find /mnt/import/Movies/ -maxdepth 1 -mmin +30 -type f -exec mv "{}" mnt/nfs-plex/Movies \;

TV:

find /mnt/import/TV/* -maxdepth 0 -mmin +30 -type d -exec mv "{}" /mnt/nfs-plex/TV \;
Score:2
jp flag

In your case you can either nest two -exec actions after each other like so:

find ... -exec chown ... {} \; -exec mv {} ... \;

Or use a bash command string like so:

find ... -exec bash -c 'chown ... "$1" && mv "$1" ...' _ {} \; 
kn flag
Thanks! The first command worked. I only know very basic commands in Linux. I need to find somewhere to learn the command line.
pierrely avatar
cn flag
https://duckduckgo.com/?t=ffab&q=bash+scripting+bible+pdf&ia=software
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.