<?xml version="1.0" encoding="UTF-8" ?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
    <title>Posteet: celos</title> 
    <link>http://www.posteet.com/</link> 
    <description>Recent posteets posted to Posteet</description>
    <ttl>60</ttl>

    
    <item>
        <title>Renomme une sequence de fichiers</title>
        <link>http://www.posteet.com/view/865</link>
        <description>
        <![CDATA[<pre>for i in $(seq -w 1 24); do mv -i &quot;$(echo *$i*.srt)&quot; &quot;$(echo *$i*.avi| sed s/avi/srt/)&quot;; done</pre>]]>        </description>
        <dc:creator>celos</dc:creator>
        <pubDate>Mon, 07 Apr 2008 16:57:26 +0000</pubDate>

    
    </item>

  
    <item>
        <title>Remplacer des caractères dans un nom de fichier</title>
        <link>http://www.posteet.com/view/863</link>
        <description>
        <![CDATA[<pre>echo $fichier | tr '$ancien_char' '$nv_char' | xargs mv $fichier</pre>]]>        </description>
        <dc:creator>celos</dc:creator>
        <pubDate>Sun, 06 Apr 2008 17:05:48 +0000</pubDate>

    
    </item>

  
    <item>
        <title>Cycle count of hard drive</title>
        <link>http://www.posteet.com/view/834</link>
        <description>
        <![CDATA[<pre>smartctl -a /dev/sda |egrep 'Power_On_Hours|Load_Cycle_Count'</pre> <a href="http://www.posteet.com/tags/hd">[hd]</a>  <a href="http://www.posteet.com/tags/sda">[sda]</a>  <a href="http://www.posteet.com/tags/smartctl">[smartctl]</a> ]]>        </description>
        <dc:creator>celos</dc:creator>
        <pubDate>Sat, 15 Mar 2008 19:09:34 +0000</pubDate>

            <category>hd</category>
            <category>sda</category>
            <category>smartctl</category>
    
    </item>

  
    <item>
        <title>Rename subtitles script</title>
        <link>http://www.posteet.com/view/124</link>
        <description>
        <![CDATA[<pre>#!/usr/bin/perl
#
# It's my first script in Perl, so be lenient.
#
# This script works only for TV shows and their subtitles !
# When you want to see your favorite tv show, with its sub, you launch the video
# with your favorite video player, and you add the path of the subtitles.
# Many video players, like mplayer, import automatically the subtitles if they 
# have the same name. This script renames the subtitles files (.srt) of a directory
# exactly like the corresponding videos (.avi).
# You won't need to specify the path of the subtitles to your video player anymore.
# 
# Example:
# Video: my_video.s04e38.something.dot.something_else.avi
# Subtitle file: video.438.srt
# After running the script, the subtitle will be named:
# my_video.s04e38.something.dot.something_else.srt
#
# The formats supported by the script:
# - sAAeBB or SAAEBB with AA the season and BB the episode.
# - ABB with A the season and BB the episode.
# - AxBB with A the season and BB the episode.
#
# If the script is launched without any arguments, then the videos and subtitles 
# directories will be set to the current directory.
#
# Options:
#       
#       -h print command list
#
# -d (-dir) &lt;videos directory&gt; 
# Specify the directory where the videos are located.
# If this option is not set, the video directory will be the current directory.
#
# -s (-sub) &lt;subtitles files directory&gt;
# Specify the directory of the subtitles files.
# If this option is not set, the subtitles directory will be the same directory as
# the videos directory. Which means that if the videos directory is not set, it will be
# the current directory.
# 
# -p (--preview)  &lt;without arguments&gt;
# Preview mode. If this options is set, the subtiles new names will be display on the
# screen without being renamed.
#
# I hope this script will be as useful as it's to me.
# 
# Enjoy your tv shows ;-)
#

use Cwd;
#use Getopt::Std;
use Getopt::Long;

my $preview = 0;
my $help = 0;
GetOptions( &quot;dir=s&quot; =&gt; \$dir, &quot;sub=s&quot; =&gt; \$sub, &quot;preview!&quot; =&gt; \$preview, &quot;help!&quot; =&gt;\$help ) or printOptions();

if ($help == 1){
  print &quot;Command list\n&quot;;
  printOptions();
}


if ($preview == 1) {print &quot;****** PREVIEW MODE ******\n&quot;;}
else {print &quot;****** RENAME MODE *******\n&quot;;}

chomp ($currentDir = getcwd());
my $videoDir = $currentDir;
my $subDir = $currentDir;

if (defined $dir){
  $videoDir = $dir;
}
print &quot;dir: $videoDir\n&quot;;

if (defined $sub) {
        $subDir = $sub;
}
else {
        $subDir = $videoDir;
}

opendir(DIR, $videoDir) || die &quot;can't opendir $videoDir: $!&quot;;
while (my $path = readdir(DIR)) { 
        push(@videosList, $path) if $path =~ m/\.avi$/;
} 
closedir(DIR);

if (!@videosList){
        print&quot;\n No videos found ! check your path !\n&quot;;
        exit();
}

$temp = getcwd();
opendir(DIR, $subDir) || die &quot;can't opendir $subDir: $!&quot;;
while (my $path = readdir(DIR)) {
        push(@subsList, $path) if $path =~ m/\.srt$/;
}
closedir(DIR);

if (!@subsList){
        print &quot;\n No subtitles found ! check your path !\n&quot;;
        exit();
}

if ($videoDir ne $currentDir){
        chdir ($videoDir) || die &quot;Can't cd to spool: $!\n&quot;;
}

foreach $f (@videosList) {
                
        ################
        # VIDEOS FILES #
        ################
        
        my @result = getSeasonEpisod($f);
        $season = @result[0];
        $episod = @result[1];

        foreach $s (@subsList) {
                
                if ($videoDir ne $subDir) {
                        chdir ($currentDir) || die &quot;Can't cd to spool: $!\n&quot;;
                        chdir ($subDir) || die &quot;Can't cd to spool: $!\n&quot;;
                }

                ####################
                # SUBTITLES FILES  #
                ####################
        
                my @result = getSeasonEpisod($s);
                $seasonSub = @result[0];
                $episodSub = @result[1];        

                if ($season == $seasonSub and $episod == $episodSub){
                        my ($vidName) = $f =~ m/(.*)\.avi$/;
                        print &quot;Rename: $s --&gt; $vidName.srt&quot;;
                        print &quot;\n&quot;;
                        if ($preview != 1){
                                rename($s,&quot;$vidName.srt&quot;) || die &quot;Cannot rename $s: $!&quot;;
                        }
                }
        }
}

# get season and episode
sub getSeasonEpisod {
        my $season = 0;
        my $episod = 0;

        # format ABB
        if(@_[0] =~ /(\d)(\d\d)/){
                $season = $1;
                $episod = $2;
        }

        # format sAAeBB
        elsif (@_[0] =~ /[sS](\d\d)[eE](\d\d)/){
                $season = $1;
                $episod = $2;
        }

        # format AxBB
        elsif (@_[0] =~ /(\d)[xX](\d\d)/){
                $season = $1;
                $episod = $2;
        }
        
        else {  
                print &quot;Video format Not Match ! \n&quot;;
        }
        
        return ($season,$episod);
}

# print options
sub printOptions(){
  print &quot;-h print command list\n&quot;;
  print &quot;-d (-dir) &lt;videos directory&gt;\n&quot;;
  print &quot;-s (-sub) &lt;subtitles files directory&gt;\n&quot;;
  print &quot;-p (--preview)  &lt;without arguments&gt;\n&quot;;
  exit();
}</pre> <a href="http://www.posteet.com/tags/perl">[perl]</a>  <a href="http://www.posteet.com/tags/rename">[rename]</a>  <a href="http://www.posteet.com/tags/subtitle">[subtitle]</a>  <a href="http://www.posteet.com/tags/videos">[videos]</a> ]]>        </description>
        <dc:creator>celos</dc:creator>
        <pubDate>Sat, 03 Nov 2007 13:25:32 +0000</pubDate>

            <category>perl</category>
            <category>rename</category>
            <category>subtitle</category>
            <category>videos</category>
    
    </item>


</channel>
</rss>
