How to change this:
for file in "$arg"/*.{jpg,jpeg,png} ; do
echo "$file" > z.txt
done
To:
for file in "$arg1"/*.{$arg2} ; do
echo "$file" > z.txt
done
Since I will get the extension list as a single (comma separated) argument. The above attempt doesn't work.