#!/bin/bash shopt -s nullglob for f in *.{mp4,MP4,mov,MOV,m4v,M4V} do # Get the dimensions of the file height=`mdls -raw -name kMDItemPixelHeight "$f"` width=`mdls -raw -name kMDItemPixelWidth "$f"` # If height is > width, create and/or put it in the "vertical" folder # Otherwise, if the height is < width, create and/or put it in the "horizontal" folder if [ $height -gt $width ] then mode="vertical" else mode="horizontal" fi # Create the folder if it doesn't exist mkdir -p $mode # Move the file to the folder mv "$f" $mode/ # Print the file name and dimensions printf "File: $f\n" printf "> Dimensions: $height x $width \n\n" done printf "All done! \n"
Write, Run & Share Bash code online using OneCompiler's Online Bash Shell for free. It's one of the robust, feature-rich Bash shell available over online and getting started with the OneCompiler's Bash Shell is simple and pretty fast. The editor shows sample boilerplate code when you choose language as Bash
. OneCompiler also has reference scripts, where you can look for the sample scripts and start coding.
Bash (Bourne Again Shell) is a shell program written by Brian Fox and is an upgraded version of Bourne Shell program 'sh'.
name="Foo"
echo $name
echo "$name"
echo "${name}"
if [ conditional-expression ]
then
statements
fi
if [ conditional-expression ]
then
statements
else
statements
fi
if [ conditional-expression ]
then
statements
elif [ conditional-expression ]
then
statements
else
statements
fi