Folder Action to convert with ffmpeg a whole subfolder of videos In another question I have found a usefull script (below) that works on single and multiple files but only when they are added directly to a folder with action enabled. Problem is my program produces in double-subfolder structure. The structure is:

 inbox_folder/name_subfolder/type_subfolder/video_files.mp4


I would like to apply conversion to subfolder burried files and have the output placed in outbox_folder with the same subfolder structure that needs to be made.

inbox and outbox are folders constantly present on desktop.

for f in "$@"
do
    /volumes/'macintosh hd'/applications/ffmpeg -i "$f" -b:v 1200k "${f%.*}.avi"
done
I actually came to a solution. The script

1) recieves a folder

2) gets folder contents repeating for subfolders

3) filters for mp4

4) runs a shell script:

for f in "$@"
do
    DIRPATH=`dirname "$f"`
    FILENAMEEXT=`basename "$f"`
    FILENAME="${FILENAMEEXT%.*}"
    EXTENSION=${f##*.}
    cd "$DIRPATH"
    mkdir -p WMV MP4
    /volumes/'macintosh hd'/applications/ffmpeg -i "$f" -b:v 4000k "$DIRPATH/WMV/$FILENAME.wmv"
    mv "$f" "$DIRPATH/MP4"
done

say "finished"