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

Khalid Baheyeldin kb at 2bits.com
Tue Jun 18 12:15:39 EDT 2013


cd /your_directory

# Iterate through files
for FILE in `find . -type f`
do
  # Don't move the file if it is already in the root directory
  if [ `dirname $FILE` != '.' ]; then
    mv $FILE .
  fi
done

# Remove the directories
for DIR in `find . -type d`
do
  if [ `dirname $FILE` != '.' ]; then
    rm -rf $DIR
  fi
done

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
>
>


-- 
Khalid M. Baheyeldin
2bits.com, Inc.
Fast Reliable Drupal
Drupal optimization, development, customization and consulting.
Simplicity is prerequisite for reliability. --  Edsger W.Dijkstra
Simplicity is the ultimate sophistication. --   Leonardo da Vinci
For every complex problem, there is an answer that is clear, simple, and
wrong." -- H.L. Mencken
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20130618/236a50d5/attachment.htm>


More information about the kwlug-disc mailing list