<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">
<DIV>I’d personally rename spaces to underscores first, then run the mass
move.</DIV>
<DIV> </DIV><PRE class="lang-bsh prettyprint prettyprinted"><CODE><SPAN class=pln> find </SPAN><SPAN class=pun>.</SPAN><SPAN class=pln> </SPAN><SPAN class=pun>-</SPAN><SPAN class=pln>name </SPAN><SPAN class=str>'* *'</SPAN><SPAN class=pln> </SPAN><SPAN class=pun>|</SPAN><SPAN class=pln> </SPAN><SPAN class=kwd>while</SPAN><SPAN class=pln> read fname
</SPAN><SPAN class=kwd>do</SPAN><SPAN class=pln>
new_fname</SPAN><SPAN class=pun>=</SPAN><SPAN class=str>`echo $fname | tr " " "_"`</SPAN><SPAN class=pln>
</SPAN><SPAN class=kwd>if</SPAN><SPAN class=pln> </SPAN><SPAN class=pun>[</SPAN><SPAN class=pln> </SPAN><SPAN class=pun>-</SPAN><SPAN class=pln>e $new_fname </SPAN><SPAN class=pun>]</SPAN><SPAN class=pln>
</SPAN><SPAN class=kwd>then</SPAN><SPAN class=pln>
echo </SPAN><SPAN class=str>"File $new_fname already exists. Not replacing $fname"</SPAN><SPAN class=pln>
</SPAN><SPAN class=kwd>else</SPAN><SPAN class=pln>
echo </SPAN><SPAN class=str>"Creating new file $new_fname to replace $fname"</SPAN><SPAN class=pln>
mv </SPAN><SPAN class=str>"$fname"</SPAN><SPAN class=pln> $new_fname
</SPAN><SPAN class=kwd>fi</SPAN><SPAN class=pln>
</SPAN><SPAN class=kwd>done</SPAN></CODE></PRE><PRE class="lang-bsh prettyprint prettyprinted"><CODE><SPAN class=kwd></SPAN></CODE> </PRE>
<DIV
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<DIV style="FONT: 10pt tahoma">
<DIV> </DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=rbclemen@gmail.com
href="mailto:rbclemen@gmail.com">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">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-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<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 class=HOEnZb>
<DIV class=h5><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>
<P>
<HR>
_______________________________________________<BR>kwlug-disc mailing
list<BR>kwlug-disc@kwlug.org<BR>http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org<BR></DIV></DIV></DIV></BODY></HTML>