Hi,<br><br>You should be able to modify this:<br><a href="http://www.sharons.org.uk/taste/archives/2012/05/index.html#e2012-05-01T00_50_12.txt">http://www.sharons.org.uk/taste/archives/2012/05/index.html#e2012-05-01T00_50_12.txt</a><br>
<br><ul><li>If you want to rename directories also, then just remove the:<span style="font-family:courier new,monospace"> -type f</span></li><li>If you want to do ALL files then remove the sections relating to name: <span style="font-family:courier new,monospace">-name &#39;*.MP3&#39;</span></li>
<li>If you want to go based on a name filter, you can actualy keep the command more simple using case insensitive name matching: <span style="font-family:courier new,monospace">-iname &quot;*.mp3&quot; </span><br></li><li>
Rather than the more convoluted: <span style="font-family:courier new,monospace">\( -name &#39;*.mp3&#39; -o -name &#39;*.MP3&#39; \)</span></li></ul><p>You should end up with something like this:</p><p>#!/bin/bash<br></p>
<p>find $1 -name &quot;* *&quot; |<br>
while IFS= read -r NAME;<br>
do<br>  DEST=`echo &quot;$NAME&quot; | tr &#39; &#39; &#39;_&#39;`<br>  mv -v &quot;${NAME}&quot; &quot;${DEST}&quot;<br>
done</p>Tested by adding that to a script: <span style="font-family:courier new,monospace">test.sh</span><br><br>Sample usage:<br><span style="font-family:courier new,monospace">[user@host]$ mkdir test</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">[user@host]$ touch test/&quot;file one.txt&quot;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">[user@host]$ touch test/&quot;file two.txt&quot;</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">[user@host]$ touch test/&quot;filethree.txt&quot;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">[user@host]$ ls test/</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">file one.txt  filethree.txt  file two.txt</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">[user@host]$ ./test.sh test/</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">`test/file one.txt&#39; -&gt; `test/file_one.txt&#39;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">`test/file two.txt&#39; -&gt; `test/file_two.txt&#39;</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">[user@host]$ ls test/</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">file_one.txt  filethree.txt  file_two.txt</span><br>
<br><br>The <span style="font-family:courier new,monospace">-name &quot;* *&quot;</span> searches for anything with a name containing a space (no pint in modifying files without spaces). You can change it to <span style="font-family:courier new,monospace">&quot;* *.mp3&quot;</span> for mp3 files only. Or use <span style="font-family:courier new,monospace">-iname</span> for case insensitive searches.<br>
<br><br><div class="gmail_quote">On 14 May 2012 23:04, sharon kimble <span dir="ltr">&lt;<a href="mailto:boudiccas@talktalk.net" target="_blank">boudiccas@talktalk.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This is probably quite easy if you already know the answer, but I&#39;m not very<br>
good at scripting.What I&#39;m looking for is a script to go through my<br>
/home/foo/Music directory converting all the album titles with spaces in to<br>
convert them to underscores.<br>
<br>
Can anyone help please?<br>
<br>
Thanks<br>
<span class="HOEnZb"><font color="#888888">Sharon.<br>
--<br>
A taste of linux = <a href="http://www.sharons.org.uk/taste/index.html" target="_blank">http://www.sharons.org.uk/taste/index.html</a><br>
efever = <a href="http://www.efever.blogspot.com/" target="_blank">http://www.efever.blogspot.com/</a><br>
efever = <a href="http://sharon04.livejournal.com/" target="_blank">http://sharon04.livejournal.com/</a><br>
Debian 6,0.5, Gnome 1:2.30+7, LibreOffice 3.4.6<br>
Registered Linux user 334501<br>
<br>
_______________________________________________<br>
Kent mailing list<br>
<a href="mailto:Kent@mailman.lug.org.uk">Kent@mailman.lug.org.uk</a><br>
<a href="https://mailman.lug.org.uk/mailman/listinfo/kent" target="_blank">https://mailman.lug.org.uk/mailman/listinfo/kent</a><br>
</font></span></blockquote></div><br>