The directory structure is as follows.
├── input
│ ├── config.ac
│ ├── dir1
│ │ ├── image2.png
│ │ └── image3.jpg
│ ├── dir2
│ └── image1.png
├── main.sh
└── output
Essentially, I am trying to run the following ./main.sh input output which I want to produce the following:
├── input
│ ├── config.ac
│ ├── dir1
│ │ ├── image2.png
│ │ └── image3.jpg
│ ├── dir2
│ └── image1.png
├── main.sh
└── output
├── dir1
│ └── image2.png
├── dir2
└── image1.png
After trying several thing such as find -exec, I went through it step by step. I'm trying to copy the internal directory structure of input into output while at the same time only copying .png files and nothing else. Here is what I have tried:
for DIR in $1/; do
mkdir $2/$DIR
cp $1/$DIR*.png $1/$DIR $2/$DIR
done
Here is my logic, the for loop will go through every directory structure in the source directory($1), it will then make the exact same directory in the destination directory($2). Now, it looks for any .png files in the current directory it is in and copies it to the exact same corresponding directory that was just created in the destination. Note, I do plan on doing some conversions to the files later on in the for loop
This doesn't seem to work at all. I get the following errors:
cp: cannot stat 'input/input/*.png': No such file or directory
cp: cannot stat 'input/input/': No such file or directory