I have some directories named FOO and BAR and etc. that have files in form
- FOO/
- 1.png
- ...
- 18.png
- BAR/
- 1.jpg
- ...
- 12.jpg
- ...
and I would like them to be all copied into the DESTINATION directory such that
- DESTINATION/
- 1.png
- ...
- 18.png
- 19.jpg
- ...
- 30.jpg
- ...
I am looking for a bash alias or function that does this.
the input should be something like function DESTINATION FOO BAR etc
if having destination directory makes the function too complicated, then please answer with the function treating the current directory as destination such so function FOO BAR etc
I made the below script for now, it works fine but only if all pictures are png and if there is no whitespace in the folder names.
if anyone has any suggestions on how to fix these bugs or how to improve the code in any way, please tell me.
#!/bin/bash
counter=1;
destination=$1;
for folder in "${@:2}"
do
for picture in $folder/*.png
do
cp $picture $destination/$counter.png;
let counter=counter+1;
done
done