Thanks once again to TB0ne for the advice. chcase looks useful for future use but I am not allowed the luxury of ripping out the white spaces on the existing server as the users will have something to say about that!
The use of a GUI is also not an option since there are literally thousands of file trees to go through – each of which may contain a Photos directory. (Plus I haven’t installed any GUI on the machine; it being a server.)
So to the problem as it remains now. I have substituted letters a, b, c, etc in place of the original characters in the file paths below but the white spaces are in the exact places that came from my session dump. This was done on a small sample of file trees copied into a safe testing area away from live data on the live server! I used sed as suggested here:-
http://mindspill.net/computing/linux...-with-sed.html
Using find with sed to show where a directory called Photos is gives a result thus:-
myname@myserver:~$ echo `find /aaaa/bbbbbbbbbb/ccccccccccccccc -name Photos | sed 's/ /\\ /g'`
/aaaa/bbbbbbbbbb/ccccccccccccccc/ddddddddd/eeeee ffff ffff fff ffffff fff ffffff ffff/gg ggg/Photos
Trying to use this result for cp comes up with errors which I assume is because it can’t handle the white spaces thus:-
myname@myserver:~$ cp -r `find /aaaa/bbbbbbbbb/cccccccccccccccc -name Photos | sed 's/ /\\ /g'` /aaaa/bbbbbbbbbb/dump/
cp: cannot stat `/aaaa/bbbbbbbbb/cccccccccccccccc/ddddddddd/eeeee': No such file or directory
cp: cannot stat `ffff': No such file or directory
cp: cannot stat `ffff': No such file or directory
cp: cannot stat `fff': No such file or directory
cp: cannot stat `ffffff': No such file or directory
cp: cannot stat `fff': No such file or directory
cp: cannot stat `ffffff': No such file or directory
cp: cannot stat `ffff/gg': No such file or directory
cp: cannot stat `ggg/Photos*': No such file or directory
I wondered if the output of the find needed to have escapes before each white space and so tried this:-
myname@myserver:~$ echo `find /aaaa/bbbbbbbbbb/ccccccccccccccc -name Photos | sed 's/ /\\\ /g'`
/aaaa/bbbbbbbbbb/ccccccccccccccc/ddddddddd/eeeee\ ffff\ ffff\ fff\ ffffff\ fff\ ffffff\ ffff/gg\ ggg/Photos
So far so good but still it seems that cp can’t cope:-
myname@myserver:~$ cp -r `find /aaaa/bbbbbbbbb/cccccccccccccccc -name Photos | sed 's/ /\\\ /g'` /aaaa/bbbbbbbbbb/dump/
cp: cannot stat `/aaaa/bbbbbbbbb/cccccccccccccccc/ddddddddd/eeeee\\': No such file or directory
cp: cannot stat `ffff\\': No such file or directory
cp: cannot stat `ffff\\': No such file or directory
cp: cannot stat `fff\\': No such file or directory
cp: cannot stat `ffffff\\': No such file or directory
cp: cannot stat `fff\\': No such file or directory
cp: cannot stat `ffffff\\': No such file or directory
cp: cannot stat `ffff/gg\\': No such file or directory
cp: cannot stat `ggg/Photos*': No such file or directory
yet if I try to copy the files by manually typing in the path, it works OK thus:-
myname@myserver:~$ cp -r /aaaa/bbbbbbbbb/cccccccccccccccc/ddddddddd/eeeee\ ffff\ ffff\ fff\ ffffff\ fff\ ffffff\ ffff/gg\ ggg/Photos/ /aaaa/bbbbbbbbbb/dump/
Clearly I still haven’t cracked this problem and so can’t progress to writing a script to work on the real data. Anyone any ideas what I’m doing wrong? Or is there a completely different approach which might work?