I actually do have another question about this script. why doesn't mv -i prompt me before changing the files when it's run like this?<br><br><div><span class="gmail_quote">On 4/7/06, <b class="gmail_sendername">Alec Warner
</b> &lt;<a href="mailto:warnera6@egr.msu.edu">warnera6@egr.msu.edu</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Caleb Cushing wrote:
<br>&gt; haven't tried it yet backing up the directory into a tarball that'll take a<br>&gt; while. Do you think you could comment it for me? basically programming of<br>&gt; any kind is a weak point for me. I'm trying to improve. but copying and
<br>&gt; pasting someone elses code may fix my issue but it won't fix my<br>&gt; understanding. &quot;give a man a fish... teach a man to fish...&quot; sort of thing.<br>&gt;<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt;On 4/6/06, Bruce Smith &lt;
<a href="mailto:blubdog@gmail.com">blubdog@gmail.com</a>&gt; wrote:<br>&gt;&gt;<br>&gt;&gt;&gt;Disclaimer, backup the directory first!&nbsp;&nbsp;:-)<br>&gt;&gt;&gt;And copy/paste exactly!<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;You can test without changing anything by adding an &quot;echo&quot; in front of
<br>&gt;&gt;&gt;the &quot;mv&quot; and optionally commenting out the &quot;set&quot; statements for better<br>&gt;&gt;&gt;readability.<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;One bug (feature?) is it will replace multiple spaces with only ONE
<br>&gt;&gt;&gt;underscore.<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;You need to run it with the filename(s) as arguments.&nbsp;&nbsp;i.e.:<br>&gt;&gt;&gt;&nbsp;&nbsp;/path/to/scriptname *<br>&gt;&gt;&gt;&nbsp;&nbsp;/path/to/scriptname a*<br>&gt;&gt;&gt;&nbsp;&nbsp;/path/to/scriptname 'File to Test this&nbsp;&nbsp;Thing 
on.TXT'<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;- BS<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;#!/bin/sh&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Run using /bin/sh, the Bourne Shell<br>&gt;&gt;&gt;infile=upper<br>&gt;&gt;&gt;outfile=lower<br>&gt;&gt;&gt;for f&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Not sure where 'f' comes from, but it's looping throught the standard input, IIRC
<br>&gt;&gt;&gt;do<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;if [ -f &quot;$f&quot; ]; then # man test will tell you what this does ;)<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;l=&quot;$(echo $f|sed 's/ /_/g'|tr &quot;[:${infile}:]&quot; &quot;[:${outfile}:]&quot;)&quot; # echo file, change ' ' to '_', globally, change upper to lower
<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if [ &quot;$f&quot; != &quot;$l&quot; ]; then # If the new filename doesn't equal the old filename..<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set -x&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# turn off echo<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mv -i &quot;$f&quot; &quot;$l&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # rename the file
<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set +x&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# turn echo back on<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fi<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; fi<br>&gt;&gt;&gt;done<br>&gt;&gt;&gt;# end of script<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;On 4/6/06, Caleb Cushing &lt; 
<a href="mailto:xenoterracide@gmail.com">xenoterracide@gmail.com</a>&gt; wrote:<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;I need/want to change the names of all the files and folders in my<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;/music<br>
&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;directory to where they don't have spaces in them and all the names<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;are in<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;lowercase. This is what I have so far:<br>&gt;&gt;&gt;&gt;
<br>&gt;&gt;&gt;&gt;#!/bin/bash<br>&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;ls -R |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# List directory recursively<br>&gt;&gt;&gt;&gt;sed -e 's/ /_/g' |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Remove spaces change them to<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt;underscore<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;tr [:upper:] [:lower:] |&nbsp;&nbsp;&nbsp;&nbsp; #change letters from upper to lower<br>&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;that gives me the output of what I would want the directory and file
<br>&gt;&gt;&gt;&gt;structure to look like when I'm done. I am unsure however how to take<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;that<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;output and move the files and directories to acually look like that
<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;when I<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;am finished. It's also the tricky part because if I don't do it<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;right...<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;well it might be an even bigger pain to fix. I pretty sure I have a
<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;lot more<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;to do to get this workable... and I'm just having problems wrapping my<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;brain<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;around it.
<br>&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;snippet:before<br>&gt;&gt;&gt;&gt;#ls -R<br>&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;./3 Doors Down:<br>&gt;&gt;&gt;&gt;Away from the Sun&nbsp;&nbsp;Seventeen Days&nbsp;&nbsp;The Better Life&nbsp;&nbsp; Thumbs.db<br>
&gt;&gt;&gt;<br>&gt;&gt;&gt;desktop.ini<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;./3 Doors Down/Away from the Sun:<br>&gt;&gt;&gt;&gt;01-When I'm Gone-3 Doors Down-Away from the Sun.mp3<br>&gt;&gt;&gt;&gt;02-Away from the Sun-3 Doors Down-Away from the 
Sun.mp3<br>&gt;&gt;&gt;&gt;03-The Road I'm On-3 Doors Down-Away from the Sun.mp3<br>&gt;&gt;&gt;&gt;04-Ticket to Heaven-3 Doors Down-Away from the Sun.mp3<br>&gt;&gt;&gt;&gt;05-Running Out of Days-3 Doors Down-Away from the 
Sun.mp3<br>&gt;&gt;&gt;&gt;06-Here Without You-3 Doors Down-Away from the Sun.mp3<br>&gt;&gt;&gt;&gt;07-I Feel You-3 Doors Down-Away from the Sun.mp3<br>&gt;&gt;&gt;&gt;08-Dangerous Game-3 Doors Down-Away from the Sun.mp3
<br>&gt;&gt;&gt;&gt;09-Changes-3 Doors Down-Away from the Sun.mp3<br>&gt;&gt;&gt;&gt;10-Going Down in Flames-3 Doors Down-Away from the Sun.mp3<br>&gt;&gt;&gt;&gt;11-Sarah Yellin'-3 Doors Down-Away from the Sun.mp3<br>&gt;&gt;&gt;&gt;
AlbumArtSmall.jpg<br>&gt;&gt;&gt;&gt;AlbumArt_{C212FF41-147D-402C-BAC5-1284F8B4C802}_Large.jpg<br>&gt;&gt;&gt;&gt;AlbumArt_{C212FF41-147D-402C-BAC5-1284F8B4C802}_Small.jpg<br>&gt;&gt;&gt;&gt;Folder.jpg<br>&gt;&gt;&gt;&gt;
Thumbs.db<br>&gt;&gt;&gt;&gt;desktop.ini<br>&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;snippet:after<br>&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;ls -R<br>&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;./3_doors_down:<br>&gt;&gt;&gt;&gt;away_from_the_sun
<br>&gt;&gt;&gt;&gt;seventeen_days<br>&gt;&gt;&gt;&gt;the_better_life<br>&gt;&gt;&gt;&gt;thumbs.db<br>&gt;&gt;&gt;&gt;desktop.ini<br>&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;./3_doors_down/away_from_the_sun:<br>&gt;&gt;&gt;&gt;01-when_i'm_gone-3_doors_down-away_from_the_sun.mp3
<br>&gt;&gt;&gt;&gt;02-away_from_the_sun-3_doors_down-away_from_the_sun.mp3<br>&gt;&gt;&gt;&gt;03-the_road_i'm_on-3_doors_down-away_from_the_sun.mp3<br>&gt;&gt;&gt;&gt;04-ticket_to_heaven-3_doors_down-away_from_the_sun.mp3
<br>&gt;&gt;&gt;&gt;05-running_out_of_days-3_doors_down-away_from_the_sun.mp3<br>&gt;&gt;&gt;&gt;06-here_without_you-3_doors_down-away_from_the_sun.mp3<br>&gt;&gt;&gt;&gt;07-i_feel_you-3_doors_down-away_from_the_sun.mp3<br>
&gt;&gt;&gt;&gt;08-dangerous_game-3_doors_down-away_from_the_sun.mp3<br>&gt;&gt;&gt;&gt;09-changes-3_doors_down-away_from_the_sun.mp3<br>&gt;&gt;&gt;&gt;10-going_down_in_flames-3_doors_down-away_from_the_sun.mp3<br>&gt;&gt;&gt;&gt;11-sarah_yellin'-3_doors_down-away_from_the_sun.mp3
<br>&gt;&gt;&gt;&gt;albumartsmall.jpg<br>&gt;&gt;&gt;&gt;albumart_{c212ff41-147d-402c-bac5-1284f8b4c802}_large.jpg<br>&gt;&gt;&gt;&gt;albumart_{c212ff41-147d-402c-bac5-1284f8b4c802}_small.jpg<br>&gt;&gt;&gt;&gt;folder.jpg
<br>&gt;&gt;&gt;&gt;thumbs.db<br>&gt;&gt;&gt;&gt;desktop.ini<br>&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;_______________________________________________<br>&gt;&gt;&gt;&gt;linux-user mailing list<br>&gt;&gt;&gt;&gt;<a href="mailto:linux-user@egr.msu.edu">
linux-user@egr.msu.edu</a><br>&gt;&gt;&gt;&gt;<a href="http://mailman.egr.msu.edu/mailman/listinfo/linux-user">http://mailman.egr.msu.edu/mailman/listinfo/linux-user</a><br>&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;
<br>&gt;&gt;&gt;<br>&gt;&gt;<br>&gt;<br>&gt;<br>&gt; ------------------------------------------------------------------------<br>&gt;<br>&gt; _______________________________________________<br>&gt; linux-user mailing list
<br>&gt; <a href="mailto:linux-user@egr.msu.edu">linux-user@egr.msu.edu</a><br>&gt; <a href="http://mailman.egr.msu.edu/mailman/listinfo/linux-user">http://mailman.egr.msu.edu/mailman/listinfo/linux-user</a><br></blockquote>
</div><br>