I have 139 directories that contain a subdirectory and files that need to be moved into the subdirectory. I thought the simplest way to do this would be to use a mv command to recursively move the files based on their file extension of which there are only two. I have something like this:
xxx_03_001
- xxx_03_001/xxx_03_001.csv
- xxx_03_001/xxx_03_001.jpg
- xxx_03_001/submissionDocumentation
xxx_03_002
- xxx_03_002/xxx_03_002.csv
- xxx_03_002/xxx_03_002.jpg
- xxx_03_002/submissionDocumentation
I want:
xxx_03_001
- xxx_03_001/submissionDocumentation/xxx_03_001.csv
- xxx_03_001/submissionDocumentation/xxx_03_001.jpg
xxx_03_002
- xxx_03_002/submissionDocumentation/xxx_03_002.csv
- xxx_03_002/submissionDocumentation/xxx_03_002.jpg
How can I move these files recursively into the submissionDocumentation subdirectory within each parent directory?
>Solution :
Run this in the top level directory:
for dir in xxx_*; do
mv "$dir"/*.{csv,jpg} "$dir"/submissionDocumentation/
done