[kwlug-disc] Need some advice/assistance on a script

Chris Irwin chris at chrisirwin.ca
Tue Jun 18 13:39:20 EDT 2013


Why all the extra effort of writing a script, when a single find command
would suffice? That way you're not passing file names between processes, or
building lists, and avoid having to remember quotes in too many places, or
set IFS, etc.

    $ find /path/to/source/files/ -type f -exec mv '{}'
/path/to/destination/ \;

If you're not sure if that is safe yet, throw an echo into the command:

    $ find /path/to/source/files/ -type f -exec echo mv '{}'
/path/to/destination/ \;

Remove empty directories when complete:

    $ find /path/to/source/files -type d -empty -delete



On Tue, Jun 18, 2013 at 11:55 AM, R. Brent Clements <rbclemen at gmail.com>wrote:

> I need to do something dramatically destructive.  I want to take a large
> directory tree of folders, and collapse them all down to their root
> folder.  File collisions are irrelevant.  How would you guys do this?
> (assume for the moment that you would).
>
> _______________________________________________
> kwlug-disc mailing list
> kwlug-disc at kwlug.org
> http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org
>
>


-- 
Chris Irwin
<chris at chrisirwin.ca>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20130618/c8c7ef5b/attachment.htm>


More information about the kwlug-disc mailing list