[kwlug-disc] Need some advice/assistance on a script
John Van Ostrand
john at vanostrand.com
Tue Jun 18 12:50:40 EDT 2013
This is a little weird but how about this:
while true; do
rmdir --ignore-fail-on-non-empty *
mv */* .
ls -l | grep "^d" > /dev/null
if $? = 1
exit
fi
done
On Tue, Jun 18, 2013 at 12:15 PM, Khalid Baheyeldin <kb at 2bits.com> wrote:
> 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
>
> _______________________________________________
> kwlug-disc mailing list
> kwlug-disc at kwlug.org
> http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org
>
>
--
John Van Ostrand
At large on sabbatical
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20130618/3ac056fb/attachment.htm>
More information about the kwlug-disc
mailing list