torrent_renamer
by eLWAux
thnk. Kaimi
http://s41.radikal.ru/i092/0811/19/cee6bab9ff55.jpg
скрипт которий переименовивает .torrent
(
маски: [torrents.ru].??????????.torrent, где ?- какая то цифра)
на файл с именем первого файла торрента ;)
например:
в папке со скриптом єсть файл: [torrents.ru].13433188.torrent
после запуска скрипт, имя файла будет:
Madagaskar.2.2008.aviю.torrent
для запуска нужет ActivePerl или другая среда
в .pl файле можна изменить:
$dir
папка, в которой переименовываться торренти:
(
например: $dir= '.'; -поточная папка
$dir= 'c:\windows' -диск c:, папка windows)
$pr
текст, которий будет добавлен до имени нового файла с самого начала
(
например: $pr= 'test'; - тогда все переименование файли будут иметь имя: test????.torrent)
использование:
1( кладем скрипт в папку с торрентами
2( запускаем скрипт
3( после завершения работи, скрипт покажет статистику:
[i] renamed: количесто_переименованих_ф айлов
[%] количесто_перемменованих_ф айлов_в_проценатах% renamed!
4( смотрим в файл result_rename.txt, там полная статистика переименованих и неПереименованих файлов
пример файла result_rename.txt:
Цитата:
renamed: 10 files
71% of all file(s)
==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-
before:
==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-
Madagaskar.torrent
[torrents.ru].11641143 - Укуренные.torrent
[torrents.ru].11697517.torrent
[torrents.ru].12933424.torrent
[torrents.ru].13433188.torrent
[torrents.ru].13504075.torrent
[torrents.ru].13669520 - Пламя и Цитрон.torrent
[torrents.ru].13743508 - После прочтения cжечь.torrent
[torrents.ru].1776583 - Отступники.torrent
[torrents.ru].4841400 - Аристотель. Все обо всем..torrent
==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-
after:
==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-
Madagaskar.2.2008.avi.torrent
ђЈђє‘ѓ‘ЂђµђЅђЅ‘‹ђµ.torrent
Hackers_1995_HDRip_Rus_PowerTracker.org.avi.torren t
Vavilon.2008.P.DVDRip.KINODOME.avi.torrent
ANNIHILATION2.avi.torrent
sway_gaming.avi.torrent
Plamja.i.Citron.2008.P.DVDRip_INTERFILM.avi.torren t
posle_proctenia_AVC.mkv.torrent
Otstupniki.avi.torrent
Aristotel.avi.torrent
==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-
not renamed:
==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-
Antix-M7.2.zip.torrent
menuetos-x86-0.84.qcow.img.zip.torrent
mona-0.3.0a8.qcow.img.zip.torrent
my.torrent
|
єсли отредактировать скрипт и сделать так что $pr='[torrent]';
тогда после работи скрипта в файле result_rename.txt ми увидем следуеще:
Цитата:
renamed: 14 files
100% of all file(s)
==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-
before:
==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-
Antix-M7.2.zip.torrent
Madagaskar.torrent
menuetos-x86-0.84.qcow.img.zip.torrent
mona-0.3.0a8.qcow.img.zip.torrent
my.torrent
[torrents.ru].11641143 - Укуренные.torrent
[torrents.ru].11697517.torrent
[torrents.ru].12933424.torrent
[torrents.ru].13433188.torrent
[torrents.ru].13504075.torrent
[torrents.ru].13669520 - Пламя и Цитрон.torrent
[torrents.ru].13743508 - После прочтения cжечь.torrent
[torrents.ru].1776583 - Отступники.torrent
[torrents.ru].4841400 - Аристотель. Все обо всем..torrent
==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-
after:
==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-
[torrent]Antix-M7.2.zip.torrent
[torrent]Madagaskar.2.2008.avi.torrent
[torrent]menuetos-x86-0.84.qcow.img.zip.torrent
[torrent]mona-0.3.0a8.qcow.img.zip.torrent
[torrent]my.torrent
[torrent]ђЈђє‘ѓ‘ЂђµђЅђЅ‘‹ђµ.torrent
[torrent]Hackers_1995_HDRip_Rus_PowerTracker.org.avi.torren t
[torrent]Vavilon.2008.P.DVDRip.KINODOME.avi.torrent
[torrent]ANNIHILATION2.avi.torrent
[torrent]sway_gaming.avi.torrent
[torrent]Plamja.i.Citron.2008.P.DVDRip_INTERFILM.avi.torren t
[torrent]posle_proctenia_AVC.mkv.torrent
[torrent]Otstupniki.avi.torrent
[torrent]Aristotel.avi.torrent
==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-
not renamed:
==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-
|
как видно все переименование файли сначала имеют текст:
[torrent], то что ми установили в $pr..
p.s.:
1( скрипт некорректо отображает UTF8 текст, как исправить незнаю; кто подскажет, буду только рад)
2( все замечания\предложения пишем тут
также, я через несколько дней доделаю скрипт, которий проверяет какие торренти загружени, какие нет, и в соответствии перемещает торретки в другие папки..
==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-
==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-
==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-
perl::code
Код:
system('cls');
##########################################################################
##########################################################################
##########################################################################
$dir = '.'; #without /
$pr = '[torrent]';
##########################################################################
##########################################################################
##########################################################################
sub saveFile
{
open(myFILE,">$_[0]") || die "error: $!";
print myFILE $_[1];
close(myFILE);
}
sub cyr #Kaimi modifed
{
($_)=@_;
y/А-яЁё/\x80-\xaf\xe0-\xf1/;
return $_;
}
sub read_str
{
if ($_[0] =~ /:$_[1](\d{0,4}):/)
{return substr($_[0], index($_[0],$_[1])+length($_[1])+length($1)+1, $1)}
else {return '';}
}
sub read_num
{
if ($_[0] =~ /$_[1]i(\d{0,64})e/)
{return $1} else {return ''}
}
sub rename_torrent #Kaimi modifed
{
my $new_name;
$new_name=cyr(read_str($_[0],'name'));
$new_name=~s/\[torrents.ru\]//ge;
return $new_name.'.torrent';
}
##########################################################################
##########################################################################
##########################################################################
system('cls');
print "--====--=--=- eLWAux -=-==-====--\n";
print "--===-== torrent renamer -=-===--\n";
print "--====-==-=-=-=-=-=-=-=--==-===--\n\n";
opendir(TEMPDIR,$dir) or die("[-] Error ($!)..");
@FILES=grep(/\.torrent$/i, readdir TEMPDIR);
closedir(TEMPDIR);
print '[i] '.@FILES." *.torrent's found\n";
print '[i] '.localtime(time())."\n";
print "--====-==-=-=-=-=-=-=-=--==-===--\n\n";
$g=0;$bef='';$aft='';$nren='';
foreach my $file(@FILES) {
$res='';
open(DESC, $file);
read(DESC,$res,-s $file);
close(DESC);
print ' '.cyr($file)."\n";
$n = $pr.rename_torrent($res);
if ($n eq $file)
{ print '[-] '.$n."\n";
$nren.=$n."\n";
} else
{ $g++;
rename $file,$n;
$bef.=$file."\n";
$aft.=$n."\n";
print '[+] '.$n."\n";
}
$i++;
}
print '[i] renamed: '.$g."\n";
print '[%] '.int(($g/@FILES)*100).'% renamed!';
saveFile('result_rename.txt',
"renamed: $g files\n".
" ".int(($g/@FILES)*100)."% of all file(s)\n".
"==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-\n".
"before:\n".
"==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-\n".
$bef."\n".
"==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-\n".
"after:\n".
"==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-\n".
$aft."\n".
"==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-\n".
"\nnot renamed:\n".
"==-=--==--=--=-=-=-=-=-=-=-=--==--==-=-=--=-=--==-\n".
$nren."\n");
<STDIN>;