This should take care of the spaces.<br><br>cd /your_directory<br><br># Iterate through files<br>for FILE in `find . -type f`<br>do<br> # Don't move the file if it is already in the root directory<br> if [ `dirname $FILE` != '.' ]; then <br>
mv "$FILE" .<br>
fi<br>done<br><br># Remove the directories<br>for DIR in `find . -type d`<br>do<br> if [ `dirname $FILE` != '.' ]; then <br> rm -rf "$DIR"<br> fi<br>done<br><br><div class="gmail_quote">On Tue, Jun 18, 2013 at 12:47 PM, R. Brent Clements <span dir="ltr"><<a href="mailto:rbclemen@gmail.com" target="_blank">rbclemen@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Khalid: As near as I can tell your script is not dealing with spaces in directory names properly. <br>
I am getting "mv: cannot stat `Show/SFG033-07': No such file or directory" when the file is actually "SFG033-07 - Little Shop Of Horrors - Skid Row.cdg" in the directory "SFGD033 - Little Shop Of Horrors & The Rocky Horror Show".<span class="HOEnZb"><font color="#888888"><br>
<br></font></span></div><span class="HOEnZb"><font color="#888888">Brent<br></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 18, 2013 at 12:15 PM, Khalid Baheyeldin <span dir="ltr"><<a href="mailto:kb@2bits.com" target="_blank">kb@2bits.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">cd /your_directory<br><br># Iterate through files<br>for FILE in `find . -type f`<br>do<br> # Don't move the file if it is already in the root directory<br>
if [ `dirname $FILE` != '.' ]; then <br> mv $FILE .<br>
fi<br>done<br><br># Remove the directories<br>for DIR in `find . -type d`<br>do<br> if [ `dirname $FILE` != '.' ]; then <br> rm -rf $DIR<br> fi<br>done<br><br><div class="gmail_quote"><div>On Tue, Jun 18, 2013 at 11:55 AM, R. Brent Clements <span dir="ltr"><<a href="mailto:rbclemen@gmail.com" target="_blank">rbclemen@gmail.com</a>></span> wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div dir="ltr">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).<br>
</div>
<br></div><div>_______________________________________________<br>
kwlug-disc mailing list<br>
<a href="mailto:kwlug-disc@kwlug.org" target="_blank">kwlug-disc@kwlug.org</a><br>
<a href="http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org" target="_blank">http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org</a><br>
<br></div></blockquote></div><span><font color="#888888"><br><br clear="all"><br>-- <br>Khalid M. Baheyeldin<br><a href="http://2bits.com" target="_blank">2bits.com</a>, Inc.<br>Fast Reliable Drupal<br>Drupal optimization, development, customization and consulting.<br>
Simplicity is prerequisite for reliability. -- Edsger W.Dijkstra<br>Simplicity is the ultimate sophistication. -- Leonardo da Vinci<br>For every complex problem, there is an answer that is clear, simple, and wrong." -- H.L. Mencken<br>
</font></span><br>_______________________________________________<br>
kwlug-disc mailing list<br>
<a href="mailto:kwlug-disc@kwlug.org" target="_blank">kwlug-disc@kwlug.org</a><br>
<a href="http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org" target="_blank">http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
kwlug-disc mailing list<br>
<a href="mailto:kwlug-disc@kwlug.org">kwlug-disc@kwlug.org</a><br>
<a href="http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org" target="_blank">http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Khalid M. Baheyeldin<br><a href="http://2bits.com" target="_blank">2bits.com</a>, Inc.<br>Fast Reliable Drupal<br>Drupal optimization, development, customization and consulting.<br>
Simplicity is prerequisite for reliability. -- Edsger W.Dijkstra<br>Simplicity is the ultimate sophistication. -- Leonardo da Vinci<br>For every complex problem, there is an answer that is clear, simple, and wrong." -- H.L. Mencken<br>