1

I have many files in the folder:

Filename1.mp4
Filename2.mp4
Filename3.mp4
Etc. 

As well as many files with added suffix to the name:

Filename1_x264.mp4
Filename2_x264.mp4
Filename3_x264.mp4
Etc.

I am trying to catch the matching pairs using find command and execute an external command on them but can't figure out a way to do it yet. Any ideas would be greatly appreciated.

codeforester
  • 39,467
  • 16
  • 112
  • 140

1 Answers1

3

With bash and its Parameter Expansion:

for i in *_x264.mp4; do 
  j="${i%*_x264.mp4}.mp4"         # remove suffix _x264.mp4 and add .mp4
  if [[ -e "$j" ]]; then
    echo "$i and $j exists"
  fi
done
Cyrus
  • 84,225
  • 14
  • 89
  • 153