I have a directory tree, where each subdirectory contains several different filetypes, I want to copy one particular filetype from each of the subdirectory, but I need to flatten the results, so that they all end up in one directory - only copying the newly added files and preserving permissions I have been using cp under zsh, with the following command line
cp -np **/*.ftype ../destination
Which has worked brilliantly up until now. However, I've just reached a limit, I'm not sure if it's the number of directories in the source directory (currently 217) or the total number of directories / desired files, (somewhere between 2672 and 2690) but suddenly I'm getting the error argument list too long: cp
I was hoping to use something like cp -np [A-Ma-m]**/*.ftype ../destination
and split the job into parts, but I get no matches found: [A-Ma-m]**/*.ftype
even though I know I have directories starting with the these ranges.
I've also tried
find Base_dir/ -iname '*.ftype' | xargs -J% cp -np % ../destination
but it seems to break the directories at each point that there's a space character in the name, so it copies nothing.
I'm sure I'm doing something silly wrong, but any help would be appreciated.
-print0
withfind
and-0
withxargs
. Also, read the manual page of each command.find . -iname '*.ftype' -print0
it only returnsfred.ftype
under the same scenario you presented in your comment.