I am wanting to copy all .jpg files from a directorie and its subdirectories into one directory however i carn't quite get it to work right. The main problem is that some of the files have spaces in their names so they get counted as multiple files. I have attempted to get the files enclosed in quotes however I can only get it to enclose all the files in one big quote or each files but in a way that still makes them go over several lines.
For instance if i have a directory tree as follows:
./Dir 1/File 1.jpg
./Dir 2/File 2.jpg
Code:
for i in `find -printf "\"%h/%f\"\n" | grep jpg`; { echo $i; }
will output:
Code:
"./Dir
1/File
1.jpg"
"./Dir
2/File
2.jpg"
I understand ls can automagically enclose the file names in quotes but it doens't appear to bable to list the directory name those files are in.