On the UNIX bash shell (specifically Mac OS X Leopard) what would be the simplest way to copy every file having a specific extension from a folder hierarchy (including subdirectories) to the same destination folder (without subfolders)?
Obviously there is the problem of having duplicates in the source hierarchy. I wouldn’t mind if they are overwritten.
Example: I need to copy every .txt file in the following hierarchy
/foo/a.txt /foo/x.jpg /foo/bar/a.txt /foo/bar/c.jpg /foo/bar/b.txt
To a folder named ‘dest’ and get:
/dest/a.txt /dest/b.txt
In bash:
findwill find all the files under the path/foomatching the wildcard*.txt, case insensitively (That’s what-inamemeans). For each file,findwill executecp {} /dest/, with the found file in place of{}.