0

I'm trying to make a script that crawls through a giving directory and list all files that are x265. Using mediainfo and can see if the file is x264 or x265, I then use sed to clean up the text. The part that is eluding me is:

1.How do i phrase a command that works in cli but not here and
2.How do i get it to include subdirectories.

#!/bin/bash
for file in ls
search='mediainfo $file | grep -E "Writing library"| sed 's/.*x//'| sed 's/\s.*$//''
 if [ $search -eq 265 ] 
 then 
  echo $file is a 265 
 else 
  echo $file is not 265 and is $search 
 fi 
sarethan
  • 13
  • 4

1 Answers1

1

You can use format of for like this:

for file in **/*

to get all files in current and subdirectories.

To assign return value to variable use backticks

search=`mediainfo $file | grep -E "Writing library"| sed 's/.*x//'| sed 's/\s.*$//'`

If you use something like you may simplify your output:

mediainfo --Inform="Video;%Codec%" $file

or

ffprobe $file 2>&1 >/dev/null | grep Stream.*Video
Romeo Ninov
  • 17,484