| Category: | Utility Scripts |
| Author/Contact Info | Miguel D Velez |
| Description: | Simple PERL/TK program that reads from a textbox input lines that have a url at the begging and converts the urls into actual link files (with the name of url's domain). I did it because I had a file with a bunch of urls that I wanted to put in my "Favorite" folder. Any comments are welcome. |
#!/usr/bin/perl
#Url2Link v0.1 coded by Miguel D Velez <migueldvelez@msn.com>
use Tk;
my $mw = new MainWindow;
my $f = $mw->Frame->pack(-fill=>'x');
$mw->title( "Url2Link v0.1" );
$mw->geometry('+100+300');
$f->Label(-text=>'Url2Link v0.1') ->pack();
$f->Label(-text=>'by Miguel D Velez') ->pack();
my $report_variable = "Type in a list of URLs and press \"Process\" bu
+tton to beging.";
my $l = $mw->Frame->pack(-side=>bottom, -fill=>x, -ipadx=>10, -ipady=>
+3);
$l->Label(-textvariable=>\$report_variable, -relief=>groove) ->pack(-f
+ill=>both, -ipady=>3);
my $b = $mw->Frame->pack(-side=>bottom, -fill=>'x', -pady=>5);
$b->Button(
-text=>"Exit",
-relief=>groove,
-command=> sub { exit } ) ->pack(-side=>bottom, -fill=>x, -ipadx=>10,
+-ipady=>3);
$b->Button(
-text=>"Process",
-relief=>groove,
-command=> sub { &process } ) ->pack(-side=>bottom, -fill=>x, -ipadx=>
+10, -ipady=>3);
my $t = $mw->Frame->pack(-padx=>5);
my $txt_body = $t->Scrolled(Text,
-scrollbars=>e,
-background=>white,
-relief=>groove,
-width=>50,
-height=>15,
-wrap=>'word') ->pack();
MainLoop;
sub process {
my @url_list = split /\s+/, $txt_body->get("1.0", "end");
my $count = 0;
if (@url_list) {
my $mkdir = mkdir "Links";
if (! $mkdir) {
$report_variable = "Could not create \"Links\" folder in current direc
+tory. $!.";
} else {
$report_variable = "\"Links\" folder created.";
}
my $chdir = chdir "Links";
if (! $chdir) {
$report_variable = "Could not access \"Links\" folder in current direc
+tory. $!.";
}
foreach(@url_list) {
if ($_ =~ /^(http|https|ftp|ftps|w).+\.([a-zA-Z0-9_-]+)\..+/) {
open FILEOUT, "> \u$2.url";
print FILEOUT '[DEFAULT]'."\n";
print FILEOUT "BASEURL=$_"."\n";
print FILEOUT '[InternetShortcut]'."\n";
print FILEOUT "URL=$_"."\n";
print FILEOUT 'Modified=0'."\n";
close(FILEOUT);
++$count
} }
chdir "..";
$txt_body->delete( "1.0", "end" );
$report_variable = "Converted $count URLs to link files. Please check
+the \"Link\" folder.";
} else {
$report_variable = "User input is empty. Please type at least one URL
+in textbox.";
} }
|
|
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: url2link
by PodMaster (Abbot) on Jan 12, 2003 at 10:58 UTC | |
|
(jeffa) Re: url2link
by jeffa (Bishop) on Jan 12, 2003 at 20:11 UTC | |
by Aristotle (Chancellor) on Jan 13, 2003 at 10:17 UTC | |
by jeffa (Bishop) on Jan 13, 2003 at 14:22 UTC | |
by m_dv (Initiate) on Jan 13, 2003 at 20:26 UTC | |
by Aristotle (Chancellor) on Jan 13, 2003 at 22:12 UTC | |
by m_dv (Initiate) on Jan 12, 2003 at 22:39 UTC | |
|
Re: url2link
by m_dv (Initiate) on Jan 12, 2003 at 05:28 UTC |