My aim is to find $files on some $devices and save them to one or more folders which are namend corresponding to a timestamp of each file. To get the timestamp I wanted to use stat.
In contrast to echo "$files", stat doesn't process each file separately. Instead it seems to process all files at once when I use "".
Do you have any suggestions on how to improve quoting or any other hints on how to make stat able to do what i want it to do? Thank you very much for your help.
#!/bin/bash
for devices in "$(ls /media/*/)";
do
for files in "$(find /media/*/$devices -iname *.jpg)";
do
echo "$files" # prints all files in separate lines
stat "$files" # seems to process all files at once
stat $files # splits file paths at spaces
done
done