Running FileBot from the console, Groovy scripting, shell scripts, etc
			
		
		
			
				
																			
								chocorem 							 
									
		Posts:  31 Joined:  21 Feb 2015, 18:31 
		
						
					
													
							
						
									
						Post 
					 
								by chocorem  14 Jul 2017, 19:29 
			
			
			
			
			
			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 ?
 
		 
				
		
		 
	 
				
		
		
			
				
								rednoah 							 
						The Source 			
		Posts:  24243 Joined:  16 Nov 2011, 08:59Location:  Taipei
				Contact: 
				
			 
				
		 
		
						
					
													
							
						
									
						Post 
					 
								by rednoah  15 Jul 2017, 03:37 
			
			
			
			
			
			Strange. Why would chown -R greg:users /folder  only change the ownership of one single file in that folder?
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								chocorem 							 
									
		Posts:  31 Joined:  21 Feb 2015, 18:31 
		
						
					
													
							
						
									
						Post 
					 
								by chocorem  07 Aug 2017, 04:16 
			
			
			
			
			
			I was wondering if the chown is executed on the directory where the movie is downloaded and then new directory created and art downloaded ?
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
		
			
				
								rednoah 							 
						The Source 			
		Posts:  24243 Joined:  16 Nov 2011, 08:59Location:  Taipei
				Contact: 
				
			 
				
		 
		
						
					
													
							
						
									
						Post 
					 
								by rednoah  07 Aug 2017, 04:26 
			
			
			
			
			
			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. 
Once
Once for each folder
Once for each file
 
 best to do a few test runs to figure out how it works
 
		 
				
		
		 
	 
				
		
		
			
				
																			
								chocorem 							 
									
		Posts:  31 Joined:  21 Feb 2015, 18:31 
		
						
					
													
							
						
									
						Post 
					 
								by chocorem  07 Aug 2017, 04:30 
			
			
			
			
			
			so I understood why it is not always working
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								chocorem 							 
									
		Posts:  31 Joined:  21 Feb 2015, 18:31 
		
						
					
													
							
						
									
						Post 
					 
								by chocorem  07 Aug 2017, 04:54 
			
			
			
			
			
			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 
		
						
					
													
							
						
									
						Post 
					 
								by chocorem  07 Aug 2017, 05:12 
			
			
			
			
			
			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.
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
		
			
				
								rednoah 							 
						The Source 			
		Posts:  24243 Joined:  16 Nov 2011, 08:59Location:  Taipei
				Contact: 
				
			 
				
		 
		
						
					
													
							
						
									
						Post 
					 
								by rednoah  07 Aug 2017, 10:07 
			
			
			
			
			
			{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]}.