#!/bin/sh
if [[ -d "$path" ]]; then
cd "$path" && echo "$PWD"
for file in *.jpg *.png *.jpeg *.gif *.gifv *.bmp; do
mv "$file" "$destpath"
done
fi
Since there are no arrays in POSIX defined. Can I put the *.jpg *.png *.jpeg *.gif *.gifv *.bmp;
in a function? Because I am using these multiple times in a script.
Is it possible to refactor cd "$path" && echo "$PWD"
in my example? e.g. get rid of the cd
command but still achieve the same effect? Thanks!
This one works for multiple file types
for file in *.{jpg,jpeg,png,gif,gifv,bmp}; do
done