samedi 18 janvier 2020

How do you exclude files that are larger than 500 megabytes from a bash?

so my goal is to convert all files that are in a certain directory with ffmpeg but not the ones that are smaller than let's say 500 megabytes?

What I made up so far is:

#!/bin/bash
mkdir converted
if [[ $(find -type f -size +500000) ]]; then
for i in *.mp4;
do ffmpeg -n -i "$i" -f mp4 -c:a aac -c:v libx265 -preset medium -crf 23 "converted/${i%}";done
fi

The script kind of works. ffmpeg starts running but it also converts the mp4s that are smaller than size +500000. I'm not good with scripting. I just started but I believe that I know where the mistake is. The if-clause tells ffmpeg to start running if there is a file within the directory that is larger than x but it doesn't tell ffmpeg to exclude these files, right? Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire