Please use ***
[code][/code]*** tags around your code and data, to preserve the original formatting and to improve readability. Do
not use quote tags, bolding, colors, "start/end" lines, or other creative techniques.
Your
find command can be made more efficient this way:
Code:
find "$BASE_DIR" -type f -name "*.$FILE_TYPE" -exec cp -t "$NEW_DIR" '{}' \+
Changing "
;" to "
+" at the end of the
-exec option makes it operate in batch mode, similar to how
xargs works. But this
requires the use of the
-t option in
cp and
mv; since the '
{}' substitution now represents all of the files found and can only appear at the
end of the command.
Notice also how I quoted all the variables, and, as Tex-Mex mentioned, especially the
-name argument. Otherwise the shell will attempt to expand
globbing characters like the '
*' and word-split all expanded strings before executing the command itself.
Proper quoting is a vitally important concept in shell scripting, so train yourself to do it correctly now.
http://mywiki.wooledge.org/Arguments
http://mywiki.wooledge.org/WordSplitting
http://mywiki.wooledge.org/Quotes