<div dir="ltr">I ran Khalid's final iteration just before I left for work. It definitely got the files moved. Left the empty directories intact, but the files seem to be ok. <br></div><div class="gmail_extra"><br><br>
<div class="gmail_quote">On Tue, Jun 18, 2013 at 1:42 PM, Jonathan D. Poole <span dir="ltr"><<a href="mailto:jpoole@digitaljedi.ca" target="_blank">jpoole@digitaljedi.ca</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 dir="ltr">
<div style="font-size:12pt;font-family:'Calibri'">
<div>I’d personally rename spaces to underscores first, then run the mass
move.</div>
<div> </div><pre><code><span> find </span><span>.</span><span> </span><span>-</span><span>name </span><span>'* *'</span><span> </span><span>|</span><span> </span><span>while</span><span> read fname
</span><span>do</span><span>
new_fname</span><span>=</span><span>`echo $fname | tr " " "_"`</span><span>
</span><span>if</span><span> </span><span>[</span><span> </span><span>-</span><span>e $new_fname </span><span>]</span><span>
</span><span>then</span><span>
echo </span><span>"File $new_fname already exists. Not replacing $fname"</span><span>
</span><span>else</span><span>
echo </span><span>"Creating new file $new_fname to replace $fname"</span><span>
mv </span><span>"$fname"</span><span> $new_fname
</span><span>fi</span><span>
</span><span>done</span></code></pre><pre><code><span></span></code> </pre>
<div style="font-size:small;font-style:normal;text-decoration:none;font-family:'Calibri';display:inline;font-weight:normal">
<div style="FONT:10pt tahoma">
<div> </div>
<div style="BACKGROUND:#f5f5f5">
<div><b>From:</b> <a title="rbclemen@gmail.com" href="mailto:rbclemen@gmail.com" target="_blank">R. Brent Clements</a> </div>
<div><b>Sent:</b> Tuesday, June 18, 2013 1:26 PM</div>
<div><b>To:</b> <a title="kwlug-disc@kwlug.org" href="mailto:kwlug-disc@kwlug.org" target="_blank">KWLUG discussion</a> </div>
<div><b>Subject:</b> Re: [kwlug-disc] Need some advice/assistance on a
script</div></div></div>
<div> </div></div>
<div style="font-size:small;font-style:normal;text-decoration:none;font-family:'Calibri';display:inline;font-weight:normal"><div><div class="h5">
<div dir="ltr">
<div>
<div>Khalid: by inserting an "echo $FILE" in the if statement, I am seeing
"Wanted/SFMW894/SFMW894-09" Every part of the directory name is being
truncated differently. The lowest directory is "SFMW891 to SFMW920 - Sunfly Most
Wanted", the next one is correct in this case, but possibly only because it
includes no spaces, and then the filename is truncated after the first
space.<br><br></div>Is this possibly a shell issue? I am using the default
shell in xubuntu.<br><br></div>Brent<br></div>
<div class="gmail_extra"><br><br>
<div class="gmail_quote">On Tue, Jun 18, 2013 at 12:56 PM, unsolicited <span dir="ltr"><<a href="mailto:unsolicited@swiz.ca" target="_blank">unsolicited@swiz.ca</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">Ech!<br><br>'rm -fr <mytopdir>'<br><br>should probably
be 'rmdir -pv <mytopdir>'<br><br>Anything left behind is non-empty and
needs further investigation.<br><br>If you check and don't care about anything
left behind, then run the 'rm -fr'.
<div>
<div><br><br>On 13-06-18 12:52 PM, unsolicited wrote:<br>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">Would:<br><br>cd <mytopdir><br>find . -type d
-execdir "mv -fv * <myparentdir>" \;<br>rm -fr
<mytopdir><br><br>do it?<br><br>i.e. find the directories, within each
found directory, execute the<br>command.<br><br>- don't move under topdir,
to facilitate rm <mytopdir><br>(mv <newdir> <mytopdir>
after the fact if useful)<br><br>- probably want a v or inquire on that last
rm, just in case something<br>didn't move.<br><br>On 13-06-18 12:15 PM,
Khalid Baheyeldin wrote:<br>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">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>On Tue, Jun 18, 2013 at 11:55 AM, R. Brent
Clements<br><<a href="mailto:rbclemen@gmail.com" target="_blank">rbclemen@gmail.com</a>>wrote:<br><br>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">I need to do something dramatically destructive.
I want to take a large<br>directory tree of folders, and collapse them
all down to their root<br>folder. File collisions are
irrelevant. How would you guys do this?<br>(assume for the moment
that you
would).<br><br>______________________________<u></u>_________________<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/<u></u>listinfo/kwlug-disc_kwlug.org</a><br>
<br><br></blockquote><br><br><br><br>______________________________<u></u>_________________<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/<u></u>listinfo/kwlug-disc_kwlug.org</a><br>
<br></blockquote><br><br>______________________________<u></u>_________________<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/<u></u>listinfo/kwlug-disc_kwlug.org</a><br>
</blockquote><br><br>______________________________<u></u>_________________<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/<u></u>listinfo/kwlug-disc_kwlug.org</a><br>
</div></div></blockquote></div>
<div> </div></div>
</div></div><p>
</p><hr><div class="im">
_______________________________________________<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>
</div><p></p></div></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></div>