Changing movie set in .nfo file with sh script

Support for Synology NAS, QNAP NAS and other Embedded Linux systems
Post Reply
suffx
Posts: 11
Joined: 17 Mar 2017, 11:12

Changing movie set in .nfo file with sh script

Post by suffx »

Im trying to write a script that will change the movie set in my nfo files to a given format. I want for example, that every Disney Movie gets the collection tag "Disney Movies". To do so I need to change the <set> tag in the nfo file.

This is my schript so far:

Code: Select all

#path=$find /volume1/pathToMovies -type f -newermt '5 minutes ago' -iname 'movie.nfo' {} +
#echo $path
path=$(grep -i "Marvel" find /volume1/pathToMovies/ -type f -newermt '5 minutes ago' -iname 'movie.nfo')

file=$(grep -i "Marvel" /volume1/pathToMovies/movie.nfo)
file2=$(grep -i "Disney" /volume1/pathToMovies/movie.nfo)
#echo $file
if [[ $file/* == *"Marvel"* ]];
then
	Collection="Marvel Movies"
	find /volume1/pathToMovies/ -type f -newermt '5 minutes ago' -iname 'movie.nfo' -exec sed -i.bak 's|<set />.*|<set>Marvel Movies</set>|g' {} +
	find /volume1/pathToMovies/ -type f -newermt '5 minutes ago' -iname 'movie.nfo' -exec sed -i.bak 's|<set>.*|<set>Marvel Movies</set>|g' {} +
	
elif [[ $file2/* == *"Disney"* ]];
then
    Collection="Disney Movies"
	find /volume1/video/Filme_Test/ -type f -newermt '5 minutes ago' -iname 'movie.nfo' -exec sed -i.bak 's|<set />.*|<set>Disney Movies</set>|g' {} +
	find /volume1/video/Filme_Test/ -type f -newermt '5 minutes ago' -iname 'movie.nfo' -exec sed -i.bak 's|<set>.*|<set>Disney Movies</set>|g' {} +

else
	echo "No Changes"
fi


This ist working, as long as i deliver the specific path to the movie.nfo file. But what i want is, that every movie.nfo file that got changed within the last 5 minutes and is located in a subdirectory of the 'pathToMovies' Directory get checked and changed if 'Marvel' or 'Disney' occurs in that file. Like i said, its working when i give the specific path, but i want this autmomatic, which is why i need to use the find command. I just dont know how to use it right.

Pls help :)
Post Reply