<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

      <title>Comments on: Rename HTML files with title tag</title>
      <link>http://ask.metafilter.com/32619/Rename-HTML-files-with-title-tag/</link>
      <description>Comments on Ask MetaFilter post Rename HTML files with title tag</description>
	  	  <pubDate>Mon, 13 Feb 2006 22:18:06 -0800</pubDate>
      <lastBuildDate>Mon, 13 Feb 2006 22:18:06 -0800</lastBuildDate>
      <language>en-us</language>
	  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
	  <ttl>60</ttl>

<item>
  	<title>Question: Rename HTML files with title tag</title>
  	<link>http://ask.metafilter.com/32619/Rename-HTML-files-with-title-tag</link>	
  	<description>I have a large number of HTML files with numeric names (001.html, 2990.html, etc.). I would like to have each file renamed with text drawn from each file&apos;s HTML title tag. I have searched high and low for a way to do this, but have not been successful. Anyone know of any scripts or apps that can do this?</description>
  	<guid isPermaLink="false">post:ask.metafilter.com,2008:site.32619</guid>
  	<pubDate>Mon, 13 Feb 2006 22:11:05 -0800</pubDate>
  	<dc:creator>tranquileye</dc:creator>
	
	<category>html</category>
	
	<category>web</category>
	
	<category>rename</category>
	
</item>
<item>
  	<title>By: charmston</title>
  	<link>http://ask.metafilter.com/32619/Rename-HTML-files-with-title-tag#509432</link>	
  	<description>I&apos;m not very familiar with the program, but I&apos;m willing to bet that you can somehow get &lt;a href=&quot;http://www.autoitscript.com/autoit3/&quot;&gt;AutoIt&lt;/a&gt; to do it for you.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.32619-509432</guid>
  	<pubDate>Mon, 13 Feb 2006 22:18:06 -0800</pubDate>
  	<dc:creator>charmston</dc:creator>
</item>
<item>
  	<title>By: sbutler</title>
  	<link>http://ask.metafilter.com/32619/Rename-HTML-files-with-title-tag#509443</link>	
  	<description>Because I like a challenge... here&apos;s a perl script to do it (tries to avoid shell meta characters and duplicates):&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;#!/usr/bin/perl -w&lt;br&gt;&lt;br&gt;use strict;&lt;br&gt;&lt;br&gt;use File::Find;&lt;br&gt;use File::Spec::Functions qw/rel2abs :DEFAULT/;&lt;br&gt;use HTML::TreeBuilder;&lt;br&gt;&lt;br&gt;if (@ARGV != 2) {&lt;br&gt;    print STDERR &amp;quot;usage: ./html-rename &amp;lt;in dir&amp;gt; &amp;lt;out dir&amp;gt;\n&amp;quot;;&lt;br&gt;    exit 1;&lt;br&gt;}&lt;br&gt;&lt;br&gt;my $in = rel2abs( shift );&lt;br&gt;my $out = rel2abs( shift );&lt;br&gt;find( \&amp;amp;wanted, $in );&lt;br&gt;&lt;br&gt;sub wanted {&lt;br&gt;    my ($fname, $tree, $title, $count);&lt;br&gt;    return unless /\.htm(l)?$/;&lt;br&gt;&lt;br&gt;    $tree = HTML::TreeBuilder-&amp;gt;new_from_file( $_ );&lt;br&gt;    if ($title = $tree-&amp;gt;look_down( &apos;_tag&apos;, &apos;title&apos; )) {&lt;br&gt;        $fname = $title-&amp;gt;as_text . &apos;.html&apos;;&lt;br&gt;        $fname =~ s/[\|&amp;amp;`\$\*\?~]//g;&lt;br&gt;    } else {&lt;br&gt;        $fname = $_;&lt;br&gt;    }&lt;br&gt;&lt;br&gt;    if (-e catfile( $out, $fname )) {&lt;br&gt;        print STDERR &amp;quot;DUPLICATE: $fname\n&amp;quot;;&lt;br&gt;        return;&lt;br&gt;    }&lt;br&gt;&lt;br&gt;    link $_, catfile( $out, $fname );&lt;br&gt;    $tree-&amp;gt;delete;&lt;br&gt;}&lt;/pre&gt;</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.32619-509443</guid>
  	<pubDate>Mon, 13 Feb 2006 23:00:54 -0800</pubDate>
  	<dc:creator>sbutler</dc:creator>
</item>
<item>
  	<title>By: normy</title>
  	<link>http://ask.metafilter.com/32619/Rename-HTML-files-with-title-tag#509678</link>	
  	<description>What OS are you using?</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.32619-509678</guid>
  	<pubDate>Tue, 14 Feb 2006 10:05:37 -0800</pubDate>
  	<dc:creator>normy</dc:creator>
</item>
<item>
  	<title>By: Kickstart70</title>
  	<link>http://ask.metafilter.com/32619/Rename-HTML-files-with-title-tag#509836</link>	
  	<description>BASH oneliner:&lt;br&gt;
&lt;br&gt;
for x in `ls *.html`; do foo=`grep &apos;&lt;title&gt;&apos; $x`; foo2=`echo $foo|sed &apos;s/&lt;title&gt;//&apos;|sed &apos;s#&lt;/title&gt;##&apos;`; mv $x $foo2.html; echo $foo2;done&lt;br&gt;
&lt;br&gt;
Note that this has no error checking and will fail on pages where the title has funky characters like spaces in it.&lt;/title&gt;</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.32619-509836</guid>
  	<pubDate>Tue, 14 Feb 2006 11:56:02 -0800</pubDate>
  	<dc:creator>Kickstart70</dc:creator>
</item>
<item>
  	<title>By: Kickstart70</title>
  	<link>http://ask.metafilter.com/32619/Rename-HTML-files-with-title-tag#509837</link>	
  	<description>Dammit. Metafilter ruined my code.&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.rafb.net/paste/results/Uv4BmH28.html&quot;&gt;check here instead&lt;/a&gt;.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.32619-509837</guid>
  	<pubDate>Tue, 14 Feb 2006 11:57:54 -0800</pubDate>
  	<dc:creator>Kickstart70</dc:creator>
</item>
<item>
  	<title>By: tranquileye</title>
  	<link>http://ask.metafilter.com/32619/Rename-HTML-files-with-title-tag#511471</link>	
  	<description>Thanks folks! Excellent help.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.32619-511471</guid>
  	<pubDate>Thu, 16 Feb 2006 10:14:59 -0800</pubDate>
  	<dc:creator>tranquileye</dc:creator>
</item>

    </channel>
</rss>
