Reputation: 1296
I have a parent directory (call it Parent) which includes nested subdirectories. I want to copy jpeg files in nested subdirectories to another directory (call it NEW). How can I do that?
Upvotes: 0
Views: 98
Reputation: 92854
find
+ cp
solution:
find Parent -type f -name"*.jpeg" -exec cp -t NEW {} +
Upvotes: 1
Reputation: 88
create a new python script with the following code:
import glob
import shutil
import os
src_dir = "your/source/dir"
dst_dir = "your/destination/dir"
for jpgfile in glob.iglob(os.path.join(src_dir, "*.jpg")):
shutil.copy(jpgfile, dst_dir)
the save it "filename.py" and in terminal run "python filename.py"
Upvotes: 1