I've read a ton of answers that are close to what I need, but not exactly, and I can't figure out how to adapt them to my needs.
I'd like to take write a bash script that takes a source folder as an argument, and perform a bunch of operations on every file (of certain type) in that folder.
src_dir=$1
for file in $src_dir/*.jpg; do
filename=`basename "$file"`
basename="${filename%.*}"
...
done
works if there are no spaces in src_dir, but I cannot figure out how to make this work if there are spaces. Usually "$src_dir"
works, but this doesn't work with for file in
.
EDIT: I should mention, I would like to be able to pass paths that contains variables that need expanding ($HOME
, $MY_PROJECT_PATH
etc. so single tick ' is also not ideal)