user35814: My folder has some video files with mp3 audio and some video files with aac audio. I want to move all files which have mp3 audio to another folder. When I asked my friend, he gave me this script:
mp3ToAAC.sh
#To convert mp3 audio to AAC
for file in *;
do
    if [ $file == "mp3ToAAC.sh" ]; then
        continue;
    fi
    if [ -f "$file" ]; then
        ffmpeg -i "$file" -acodec aac -vcodec copy ../"$file"
    fi 
done

That will convert all video files with audio mp3 to aac. Before using this, I want to move the files which have mp3 audio to another directory. I want to run this script only on those files. How to do that?

user35815: I think that the question has an error. I shall ask the OP to correct it.
The code to move files is:
#To move mp3 video to parent
for file in *;
do
    if [ "$file" == "moveMp3.sh" ]; then
        continue;
    fi
    if [ -f "$file" ]; then
        audioFormat=$(ffprobe -loglevel error -select_streams a:0 -show_entries stream=codec_name -of default=nw=1:nk=1 "$file")
        if [ -z $audioFormat ]; then
            continue;
        fi
        if [ $audioFormat == "mp3" ]; then
            mv "$file" ../"$file"
        fi
    fi
done

The code to convert mp3 can be:
#To convert mp3 audio to AAC
for file in *;
do
    if [ $file == "mp3ToAAC.sh" ]; then
        continue;
    fi
    if [ -f "$file" ]; then
        ffmpeg -i "$file" -map 0 -c copy -c:a:0 aac ../"$file"
    fi 
done


35814: <p>My folder has some video files with mp3 audio and some video files with aac audio. I want to move all files which have mp3 audio to another folder. When I asked my friend, he gave me this script:</p>
<p><strong>mp3ToAAC.sh</strong></p>
<pre><code>#To convert mp3 audio to AAC
for file in *;
do
    if [ $file == &quot;mp3ToAAC.sh&quot; ]; then
        continue;
    fi
    if [ -f &quot;$file&quot; ]; then
        ffmpeg -i &quot;$file&quot; -acodec aac -vcodec copy ../&quot;$file&quot;
    fi 
done
</code></pre>
<p>That will convert all video files with audio mp3 to aac. Before using this, I want to move the files which have mp3 audio to another directory. I want to run this script only on those files. How to do that?</p>
 35815: <p>I think that the question has an error. I shall ask the OP to correct it.</p>
<p>The code to move files is:</p>
<pre><code>#To move mp3 video to parent
for file in *;
do
    if [ &quot;$file&quot; == &quot;moveMp3.sh&quot; ]; then
        continue;
    fi
    if [ -f &quot;$file&quot; ]; then
        audioFormat=$(ffprobe -loglevel error -select_streams a:0 -show_entries stream=codec_name -of default=nw=1:nk=1 &quot;$file&quot;)
        if [ -z $audioFormat ]; then
            continue;
        fi
        if [ $audioFormat == &quot;mp3&quot; ]; then
            mv &quot;$file&quot; ../&quot;$file&quot;
        fi
    fi
done
</code></pre>
<p>The code to convert mp3 can be:</p>
<pre><code>#To convert mp3 audio to AAC
for file in *;
do
    if [ $file == &quot;mp3ToAAC.sh&quot; ]; then
        continue;
    fi
    if [ -f &quot;$file&quot; ]; then
        ffmpeg -i &quot;$file&quot; -map 0 -c copy -c:a:0 aac ../&quot;$file&quot;
    fi 
done
</code></pre>
