[Linux-disciples] Moving files

Adam Rosi-Kessel adam at rosi-kessel.org
Mon Jun 5 13:21:08 EDT 2006


Adam Rosi-Kessel wrote:
> Stephen R Laniel wrote:
>> On Mon, Jun 05, 2006 at 10:34:47AM -0500, Karl Sokol wrote:
>>> I want to move all of the files on my computer that have exactly 4 letters and
>>> a .mp3 extension, to a single folder.   Is this possible.
>> Yes. You'll do something like this:
>> find . -iregex '^[[:alnum:]\{4\}\.mp3$' -depth mv '{}' [newfolder] \;
> That seems to be missing an -exec, should be:
> find . -iregex '^[[:alnum:]\{4\}\.mp3$' -depth -exec mv '{}' [newfolder] \;

It's also missing a close brace:

find . -iregex '^[[:alnum:]]\{4\}\.mp3$' -depth -exec mv '{}' [newfolder] \;

I would go with the simpler:

find . -type f -iregex '^....\.mp3$' -exec mv '{}' [newfolder] ';'

which I think in all imaginable cases does the same thing.


More information about the Linux-disciples mailing list