Moving specific files with find, perl and xargs
Summary:
find -print0|perl -n0 -e 'print if m/\(\d+\)/'| xargs -0 -I xxx mv xxx copies/
I needed to find all files that had a parenthesized number in them, such as "filename(3).txt", and move them to a copies folder.
It is a good idea to use -print0 to cater for complex filenames on the find side, and in perl you tell perl to go into null terminated mode with the "-0" switch as seen above.
If you then pipe it further to xargs, you use the "-0" switch to tell xargs that the file names are null terminated. xargs will assume you want the file names as the last part of the command given to xargs, but for mv you do not want this, since the last part of the command should be the destination folder. The -I switch allows you to specify a placeholder identifier for the input to xargs. Above I have chosen "xxx" for this. Hence in "mv xxx copies/", xxx is replaced with the file name.