<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Howto strip/crop and rename multiple file names in a commad line (Linux)</title>
	<atom:link href="http://blog.mymediasystem.net/uncategorized/rename-multiple-files/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mymediasystem.net/uncategorized/rename-multiple-files/</link>
	<description>MyMediaSystem - 1080p - AVCHD - H.264 - Linux - GPS &#38; GPX</description>
	<lastBuildDate>Fri, 12 Mar 2010 09:27:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: acmelab68</title>
		<link>http://blog.mymediasystem.net/uncategorized/rename-multiple-files/comment-page-1/#comment-1988</link>
		<dc:creator>acmelab68</dc:creator>
		<pubDate>Fri, 12 Jun 2009 19:47:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mymediasystem.net/?p=1722#comment-1988</guid>
		<description>&lt;a href=&quot;#comment-1987&quot; rel=&quot;nofollow&quot;&gt;@Wizzu&lt;/a&gt; 
Cool!
The &#039;s///&#039; trick is cool, and I&#039;ve discovered it for me also. Actually I wrote a little article about it immediately, because I was so excited ;-) See &lt;a href=&quot;http://blog.mymediasystem.net/uncategorized/regex-renaming-with-se/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.

But your &lt;code&gt;for; do ... ;done&lt;/code&gt; line was a quite a surprise, because I didn&#039;t know the &#039;basename NAME &lt;strong&gt;[SUFFIX]&lt;/strong&gt;&#039; trick. This is really cool, and is much cleaner this way!

Thanks a lot!</description>
		<content:encoded><![CDATA[<p><a href="#comment-1987" rel="nofollow">@Wizzu</a><br />
Cool!<br />
The &#8217;s///&#8217; trick is cool, and I&#8217;ve discovered it for me also. Actually I wrote a little article about it immediately, because I was so excited <img src='http://blog.mymediasystem.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  See <a href="http://blog.mymediasystem.net/uncategorized/regex-renaming-with-se/" rel="nofollow">here</a>.</p>
<p>But your <code>for; do ... ;done</code> line was a quite a surprise, because I didn&#8217;t know the &#8216;basename NAME <strong>[SUFFIX]</strong>&#8216; trick. This is really cool, and is much cleaner this way!</p>
<p>Thanks a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wizzu</title>
		<link>http://blog.mymediasystem.net/uncategorized/rename-multiple-files/comment-page-1/#comment-1987</link>
		<dc:creator>Wizzu</dc:creator>
		<pubDate>Thu, 11 Jun 2009 19:44:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mymediasystem.net/?p=1722#comment-1987</guid>
		<description>Well, my rename script can do that with the s/// expression easily (&#039;s/\.avi$/.mpg/&#039;) but if that&#039;s not what you want, then I suppose your shell commands work fine.

I should point you there&#039;s a &quot;basename&quot; command which gives you the file&#039;s name without the extension, so no need to do echo/tr trickery.
One web page I just googled shows it as:

for old in *.avi; do mv &quot;$old&quot; &quot;`basename $old .avi`.mpg&quot;; done

You can work also with filenames containing spaces if you put double quotes in proper places (I added them in the above).</description>
		<content:encoded><![CDATA[<p>Well, my rename script can do that with the s/// expression easily (&#8217;s/\.avi$/.mpg/&#8217;) but if that&#8217;s not what you want, then I suppose your shell commands work fine.</p>
<p>I should point you there&#8217;s a &#8220;basename&#8221; command which gives you the file&#8217;s name without the extension, so no need to do echo/tr trickery.<br />
One web page I just googled shows it as:</p>
<p>for old in *.avi; do mv &#8220;$old&#8221; &#8220;`basename $old .avi`.mpg&#8221;; done</p>
<p>You can work also with filenames containing spaces if you put double quotes in proper places (I added them in the above).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: acmelab68</title>
		<link>http://blog.mymediasystem.net/uncategorized/rename-multiple-files/comment-page-1/#comment-1958</link>
		<dc:creator>acmelab68</dc:creator>
		<pubDate>Sun, 10 May 2009 18:57:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mymediasystem.net/?p=1722#comment-1958</guid>
		<description>&lt;a href=&quot;#comment-1956&quot; rel=&quot;nofollow&quot;&gt;@Wizzu&lt;/a&gt; 
Really cool!
Another question I&#039;ve been asking myself for ages now is, how to do this DOS example in a bash shell:

&lt;code&gt;move *.avi *.mpg&lt;/code&gt;

The bash solution for me atm is still:

&lt;code&gt;for I in $(ls *.avi)
do 
   WITHOUTH_AVI=$(echo $I &#124; tr -d &quot;.avi$&quot;)
   mv $I &quot;$WITHOUT_AVI&quot;.mpg; 
done&lt;/code&gt;


and in this example must not be SPACES in the filename.

Does anybody have another soltion?</description>
		<content:encoded><![CDATA[<p><a href="#comment-1956" rel="nofollow">@Wizzu</a><br />
Really cool!<br />
Another question I&#8217;ve been asking myself for ages now is, how to do this DOS example in a bash shell:</p>
<p><code>move *.avi *.mpg</code></p>
<p>The bash solution for me atm is still:</p>
<p><code>for I in $(ls *.avi)<br />
do<br />
   WITHOUTH_AVI=$(echo $I | tr -d ".avi$")<br />
   mv $I "$WITHOUT_AVI".mpg;<br />
done</code></p>
<p>and in this example must not be SPACES in the filename.</p>
<p>Does anybody have another soltion?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wizzu</title>
		<link>http://blog.mymediasystem.net/uncategorized/rename-multiple-files/comment-page-1/#comment-1956</link>
		<dc:creator>Wizzu</dc:creator>
		<pubDate>Sun, 10 May 2009 16:32:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mymediasystem.net/?p=1722#comment-1956</guid>
		<description>Oops, looks like the HTML ate part of the code.

Line 7 be like this (I hope this works now):

@ARGV = &lt;STDIN&gt;;</description>
		<content:encoded><![CDATA[<p>Oops, looks like the HTML ate part of the code.</p>
<p>Line 7 be like this (I hope this works now):</p>
<p>@ARGV = &lt;STDIN&gt;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wizzu</title>
		<link>http://blog.mymediasystem.net/uncategorized/rename-multiple-files/comment-page-1/#comment-1955</link>
		<dc:creator>Wizzu</dc:creator>
		<pubDate>Sun, 10 May 2009 16:30:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mymediasystem.net/?p=1722#comment-1955</guid>
		<description>There&#039;s probably a few hundred if not thousands of Linux rename scripts/tips out there.

Personally, I&#039;m using something I picked out of a Perl book examples a long time ago, and called it &quot;rename&quot; not surprisingly. It does require you&#039;re familiar with (perl) regular expressions; if you&#039;re not, then this is probably not for you.

Your example would be done like this:

rename &#039;s/\[.*\]//&#039; *.mp3

(with &lt;i&gt;s/ ... / ... /&lt;/i&gt;  being the substitute operation).

Here&#039;s the perl code:
&lt;code&gt;
#!/usr/bin/perl

# Usage: rename perlexpr [files]

($op = shift) &#124;&#124; die &quot;Usage: rename perlexpr [filenames]\n&quot;;
if (!@ARGV) {
  @ARGV = ;
  chop(@ARGV);
}
$filenum = 0;
for (@ARGV) {
  $filenum++;
  $was = $_;
  eval $op;
  die $@ if $@;
  rename($was,$_) unless $was eq $_;
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>There&#8217;s probably a few hundred if not thousands of Linux rename scripts/tips out there.</p>
<p>Personally, I&#8217;m using something I picked out of a Perl book examples a long time ago, and called it &#8220;rename&#8221; not surprisingly. It does require you&#8217;re familiar with (perl) regular expressions; if you&#8217;re not, then this is probably not for you.</p>
<p>Your example would be done like this:</p>
<p>rename &#8217;s/\[.*\]//&#8217; *.mp3</p>
<p>(with <i>s/ &#8230; / &#8230; /</i>  being the substitute operation).</p>
<p>Here&#8217;s the perl code:<br />
<code><br />
#!/usr/bin/perl</p>
<p># Usage: rename perlexpr [files]</p>
<p>($op = shift) || die "Usage: rename perlexpr [filenames]\n";<br />
if (!@ARGV) {<br />
  @ARGV = ;<br />
  chop(@ARGV);<br />
}<br />
$filenum = 0;<br />
for (@ARGV) {<br />
  $filenum++;<br />
  $was = $_;<br />
  eval $op;<br />
  die $@ if $@;<br />
  rename($was,$_) unless $was eq $_;<br />
}<br />
</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>
