Page 1 of 1

change directory permissions

Posted: 14 Jul 2017, 19:29
by chocorem
Hello,

I'm running a post process script on downloader.

Code: Select all

filebot -script fn:amc --output "$CONFIG_OUTPUT" --action move --conflict override -non-strict --log-file /var/log/filebot/amc-jdown.log --def movieFormat='Movies/{any{localize.French.collection/"($y) $localize.Fre.n - $vf.$vc.$ac"}{"($y) $localize.Fre.n - $vf.$vc.$ac"}}/{localize.Fre.n} ({y})' --def "exec=chmod -R 775 '{folder}/' ; chown -R greg:users '{folder}/'" --def music=n artwork=y subtitles=en ut_dir="$ARG_PATH" ut_kind="multi" ut_title="$ARG_NAME" ut_label="$ARG_LABEL"
jd is running on a ubuntu server and needs to be under root. Thanks to the

Code: Select all

--def "exec=chmod -R 775 '{folder}/' ; chown -R greg:users '{folder}/'"
the movie the permissions and the ownership of the movie itself is changed to greg:users, but the folder and also all the downloaded posters stays under root.

Code: Select all

-rw-r--r-- 1 root root       782660 Jul  1 15:10 clearart.png
-rw-r--r-- 1 root root       725675 Jul  1 15:10 disc.png
-rw-r--r-- 1 root root       196678 Jul  1 15:09 fanart.jpg
-rw-r--r-- 1 root root       400830 Jul  1 15:10 folder.jpg
-rw-r--r-- 1 greg users 10864880678 Jul  1 15:09 Les Figures de l'ombre (2016).mkv
-rw-r--r-- 1 root root        50871 Jul  1 15:10 logo.png
-rw-r--r-- 1 root root         5305 Jul  1 15:09 movie.nfo
-rw-r--r-- 1 root root       400830 Jul  1 15:09 poster.jpg
is there a way to change all the directory and the content permissions and ownership ?

Re: change directory permissions

Posted: 15 Jul 2017, 03:37
by rednoah
Strange. Why would chown -R greg:users /folder only change the ownership of one single file in that folder?

Re: change directory permissions

Posted: 07 Aug 2017, 04:16
by chocorem
I was wondering if the chown is executed on the directory where the movie is downloaded and then new directory created and art downloaded ?

or is the chown executed on the new file and directory ? Solution 1 would explain it ?

Re: change directory permissions

Posted: 07 Aug 2017, 04:26
by rednoah
That's up to you. Depends on your --def exec expression.

FileBot will generate commands for all processed files but only execute each unique command once.

Code: Select all

echo Hello
Once

Code: Select all

echo {folder}
Once for each folder

Code: Select all

echo {file} 
Once for each file



:idea: best to do a few test runs to figure out how it works

Re: change directory permissions

Posted: 07 Aug 2017, 04:30
by chocorem
so I understood why it is not always working

--def "exec=chmod -R 775 '{folder}/' ; chown -R greg:users '{folder}/'"

is not working when the ;movie title has ' in the title, so the string is not quoted correctly
example : chmod -R 775 '/mnt/raid0/medias/videos/Movies/(2017) Si j'étais un homme - 720p.x264.AC3/'

the command should look like chmod -R 775 "/mnt/raid0/medias/videos/Movies/(2017) Si j'étais un homme - 720p.x264.AC3/" to work , but I do not know how to define the def expression as there are already " to quote the def expression ....

Re: change directory permissions

Posted: 07 Aug 2017, 04:54
by chocorem
found the response myself , had to escape the double quote

Code: Select all

--def "exec=chmod -R 775 \"{folder}/\" ; chown -R greg:users \"{folder}/\""

Re: change directory permissions

Posted: 07 Aug 2017, 05:12
by chocorem
The only thing that is not working now is if the movies is part of a collection, {folder} is pointing to the the movies folder, so the command is not changing the permission of the collection folder. Same for TV shows, the command is changing the permissions of the "Season 01" folder, but not from the TV show folder.

is there a way to get those folders in a command ?

Re: change directory permissions

Posted: 07 Aug 2017, 10:07
by rednoah
{folder} is the parent folder of {f}. If you want to go up one level then you can use {folder.dir} or {f.dir.dir} or {f[-3]}.

You could always just refer to the {output} folder. Not the most efficient, but it'll catch all files and folders in a single command.