change directory permissions

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
chocorem
Posts: 31
Joined: 21 Feb 2015, 18:31

change directory permissions

Post 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 ?
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: change directory permissions

Post by rednoah »

Strange. Why would chown -R greg:users /folder only change the ownership of one single file in that folder?
:idea: Please read the FAQ and How to Request Help.
chocorem
Posts: 31
Joined: 21 Feb 2015, 18:31

Re: change directory permissions

Post 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 ?
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: change directory permissions

Post 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
:idea: Please read the FAQ and How to Request Help.
chocorem
Posts: 31
Joined: 21 Feb 2015, 18:31

Re: change directory permissions

Post 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 ....
chocorem
Posts: 31
Joined: 21 Feb 2015, 18:31

Re: change directory permissions

Post 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}/\""
chocorem
Posts: 31
Joined: 21 Feb 2015, 18:31

Re: change directory permissions

Post 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 ?
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: change directory permissions

Post 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.
:idea: Please read the FAQ and How to Request Help.
Post Reply