tags:

views:

19

answers:

1

I am trying to write a simple command that searches through a music directory for all files of a certain type and copies them to a new directory. I would be fine if the files didn't have spaces.

I'm using a script from the following question, but it fails for spaces: http://stackoverflow.com/questions/2640260/bash-script-problem-find-mv-tilde-files-created-by-gedit

Any suggestions on how I can handle spaces, once I'm satisfied that all the files are being listed, I'll change echo to cp

for D in `find . -name "*.wma*"`; do echo "${D}"; done
+1  A: 

You probably want to do this instead:

find . -name *.wma -exec echo "{}" \;
vanza
that didn't work. Can you add an explanation of how to handle the spaces?
Eric U.
Didn't work how?If you check find's man page, it says: "The string `{}' is replaced by the current file name". So if you put quotes around it, like in my example, you'll be handling spaces.
vanza
Didn't work because I overlooked the \; and it kept giving me a <code>find: -exec: no terminating ";" or "+"</code>Thanks for your help
Eric U.