Background
iPhone has live photo's, i thought i could use VLC on Windows or some iPhone app to take a still of the desired frame. Long story short, you can but the quality of the image as well as the resolution is drastically lowered. So i gave up on this.
Problem
I have actual movie files hidden along side the Live Photo's
My Goal
Using cygwin to run a bash shell script to iterate through 0000 to 9999 and find all JPG and MOV files that have the same name ONLY.
Problem
I am having issues with the regex
I tried ls | grep -E "IMG_0016\.(JPG|MOV)"
I need a bash script that will return true if it finds both a jpg and mov file for the given filename. Is this doable in a one liner? Can anyone give me some ideas on how to make the above bash command more robust?
It finds both but how do i say, okay, good job, you have both, now do the following with those two files.
EDIT
!/bin/bash
for i in $(seq -f "%04g" 0 20)
do
FILENAME="IMG_$i"
#echo "$FILENAME"
var=$(ls -l | grep "$FILENAME" | grep -E "(JPG|MOV)" | wc -l)
if [ "$var" == 2 ] ; then
echo we found both for $FILENAME
echo $var
fi
done
Output
we found both for IMG_0018
2
we found both for IMG_0019
2
EXPECTED
files in directory are:
- IMG_0016.JPG
- IMG_0018.JPG
- IMG_0018.MOV
- IMG_0019.JPG
- IMG_0019.MOV
COMMENT
This is good in the sense that it looks for only 2 files but there has to be a better way to say find ONE JPG and ONE MOV??
EDIT 2
#!/bin/bash
for i in $(seq -f "%04g" 0 20)
do
FILENAME="IMG_$i"
#echo "$FILENAME"
var=$(ls -l | grep "$FILENAME" | grep -E "(JPG|MOV)" | wc -l)
#echo $var
if [ "$var" == 2 ] ; then
#echo we found both for $FILENAME
var=$(ls -l | grep "$FILENAME" | grep -E JPG | wc -l)
if [ "$var" == 1 ] ; then
var=$(ls -l | grep "$FILENAME" | grep -E MOV | wc -l)
if [ "$var" == 1 ] ; then
mv "D:\Mike\Pictures\TEST\\$FILENAME.JPG" "D:\Mike\Pictures\TEST\MATCH\\$FILENAME.JPG"
mv "D:\Mike\Pictures\TEST\\$FILENAME.MOV" "D:\Mike\Pictures\TEST\MATCH\\$FILENAME.MOV"
fi
fi
fi
done