First of all, I'm not allowed to use more for or while loops because this is task for university.
I have the following:
for i in {00..20}
do
users=( $(ls "$dir"/"$1" | grep "room_${i}_*" | cut -d '.' -f 1 | cut -d '_' -f 3-4 | sort | uniq) )
cd "$dir"/"$2"/r"${i}" || exit
mkdir -p "${users[@]}"/{MP4,MOV,AVI,WMV,MKV}
done
I have bunch of videos named room_XX_user_Y.ext, where XX is a number between 00 and 20, Y is unknown and ext is one of {MP4,MOV,AVI,WMV,MKV}. So, I have to move the file to /rXX/user_Y/ext/ and I have to create all of them except rXX (r stands for room). Every user has a video with this extensions.
I'm able to do everything except creating all the {MP4,MOV,AVI,WMV,MKV} directories inside the user_Y directory. If the users for a room are a, b, c and d, the directories for extensions will only be created on the user_d directory.
Thank you all.