I am using a command to rename files called “filebot”, this command analyze filename and search in internet the best name for this file, if a best name is found the file is processed and renamed but if not found a coincidence filebot dont rename the file.
I want abort if filebot respond “Processed 0 files”, so i can know if this file could not be processed. A filebot command example:
filebot -rename “movie 43.mkv” --db TheMovieDB -non-strict --lang en --filter “y > 2005” --action test
this command return me these lines in console when press enter:
Rename movies using [TheMovieDB]
Auto-detect movie from context: [/Volumes/Descargas/Movie 43.mkv]
Apply Filter: {y > 2005}
Include [Movie 43 (2013)]
Include [Movie (2007)]
[TEST] Rename [/Volumes/Descargas/Movie 43.mkv] to [Movie 43 (2013).mkv] Processed 1 files
Done ?(???)?
As we can see “Processed 1 files” all work fine. But how i can “abort” the command if “Processed 0 files”?. I had tested this
filebot -rename “movie 43.mkv” --db TheMovieDB -non-strict --lang en --filter “y > 2005” --action test
if [$? -eq “Processed 1 files”]; then
exit 1
else
exit 0
but no luck
EDIT: With /bin/zsh and
j=$(filebot -rename “movie 43.mkv” --db TheMovieDB -non-strict --lang en --filter “y > 2005” --action test)
if [$j -eq “Processed 0 files”]; then
exit 1
else
exit 0
o=$( filebot -rename "movie 43.mkv" --db TheMovieDB -non-strict --lang en --filter "y > 2005" --action test )
if [ "$o" = "Processed 1 files" ]
then
echo true
else
echo false
fi
Allways return me “false”, but command only return:
Rename movies using [TheMovieDB]
Auto-detect movie from context: [/Volumes/Descargas/Movie 43.mkv]
Apply Filter: {y > 2005}
Include [Movie 43 (2013)]
Include [Movie (2007)]
[TEST] Rename [/Volumes/Descargas/Movie 43.mkv] to [Movie 43 (2013).mkv]
Processed 1 files
Done ?(?????)?
Maybe all return is a long string, and i must search for “Processed 1 files” in this string… something like
j=$ (Exist the string "Processed 1 files" in "filebot -rename "movie 43.mkv" --db TheMovieDB -non-strict --lang en --filter "y > 2005" --action test" ??)
if [ "$j" = true ]
then
echo true
else
echo false
fi
But i dont know how search this partial string "Processed 1 files"
Thanks for your response!