Schrift
Wiki:Tipp zum Debugging: use Data::Dumper; local $Data::Dumper::Useqq = 1; print Dumper \@var;
[thread]6811[/thread]

Perl skript unterverzeichnisse öffnen



<< >> 4 Einträge, 1 Seite
Gast Gast
 2005-03-22 19:56
#52887 #52887
Dieses script wandelt mp3 und wma s in ogg um nun möchte ich das es auch noch die Unterorderner des jeweiligen ordners öffnet und die enthaltenen lieder umwandelt
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#! /usr/bin/perl 

### mp3 and wma to ogg by darklinux presents

use warnings;

$dir=`pwd`;

chomp($dir);

opendir(CHECKDIR,"$dir");

while ($file=readdir(CHECKDIR)) {
$orig_file=$file;

if($orig_file =~ m/\.mp3$/i)
{
print "Checking file: $orig_file\n";
$new_wav_file=$orig_file;$new_wav_file=~s/\.mp3/\.wav/;
$new_ogg_file=$orig_file;$new_ogg_file=~s/\.mp3/\.ogg/;
$convert_to_wav="mplayer \"./$orig_file\" -ao pcm -aofile \"./$new_wav_file\"";
$convert_to_ogg="oggenc -q 4 \"./$new_wav_file\" \"./$new_ogg_file\"";
$remove_wav="rm -rf \"./$new_wav_file\"";
$remove_mp3="rm -rf \"./$orig_file\"";
print "EXEC 1: $convert_to_wav\n";
$cmd=`$convert_to_wav`;
print "EXEC 2: $convert_to_ogg\n";
$cmd=`$convert_to_ogg`;
print "REMOVE WAV: $remove_wav\n";
$cmd=`$remove_wav`;
print "REMOVE MP3: $remove_mp3\n";
$cmd=`$remove_mp3`;
print "\n\n";
}

elsif($orig_file =~ m/\.wma$/i)
{
print "Checking file: $orig_file\n";
$new_wav_file=$orig_file;$new_wav_file=~s/\.wma/\.wav/;
$new_ogg_file=$orig_file;$new_ogg_file=~s/\.wma/\.ogg/;
$convert_to_wav="mplayer \"./$orig_file\" -ao pcm -aofile \"./$new_wav_file\"";
$convert_to_ogg="oggenc -q5 \"./$new_wav_file\" \"./$new_ogg_file\"";
$remove_wav="rm -rf \"./$new_wav_file\"";
$remove_wma="rm -rf \"./$orig_file\"";
print "EXEC 1: $convert_to_wav\n";
$cmd=`$convert_to_wav`;
print "EXEC 2: $convert_to_ogg\n";
$cmd=`$convert_to_ogg`;
print "REMOVE WAV: $remove_wav\n";
$cmd=`$remove_wav`;
print "REMOVE WMA: $remove_wma\n";
$cmd=`$remove_wma`;
print "\n\n";
}

}

use Gtk;
use strict;
set_locale Gtk;
init Gtk;
my $false = 0;
my $true = 1;
my $window = new Gtk::Window( "toplevel" );
my $button = new Gtk::Button( "Fertig" );
$window->signal_connect( "delete_event", \&CloseAppWindow );
$button->signal_connect( "clicked", \&CloseAppWindow );
$button->show();
$window->border_width( 15 );
$window->add( $button );
$window->show();
main Gtk;
exit( 0 );
sub CloseAppWindow
{
Gtk->exit( 0 );
system('exit');
return $false;
exit
}
ptk
 2005-03-22 20:23
#52888 #52888
User since
2003-11-28
3645 Artikel
ModeratorIn
[default_avatar]
use File::Find
Tuxist
 2005-03-22 20:35
#52889 #52889
User since
2005-03-22
1 Artikel
BenutzerIn
[default_avatar]
Wie kann ich das implentieren ?
renee
 2005-03-23 10:24
#52890 #52890
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
ungetestet:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#! /usr/bin/perl

use Gtk;
use strict;
use warnings;
use File::Find;

### mp3 and wma to ogg by darklinux presents


my $dir=`pwd`;
chomp $dir;

my @files;
find(\&get_files,$dir);

conver_file($_) for(@files);

#==
# Gtk-part
#==
set_locale Gtk;
init Gtk;
my $false = 0;
my $true = 1;
my $window = new Gtk::Window( "toplevel" );
my $button = new Gtk::Button( "Fertig" );
$window->signal_connect( "delete_event", \&CloseAppWindow );
$button->signal_connect( "clicked", \&CloseAppWindow );
$button->show();
$window->border_width( 15 );
$window->add( $button );
$window->show();
main Gtk;
exit( 0 );
sub CloseAppWindow
{
 Gtk->exit( 0 );
 system('exit');
 return $false;
 exit
}

#------------------------
# Subroutines
#------------------------

sub convert_file{
 my ($file) = @_;
 my %valid = (mp3 => 4, wma => 5);
 my $extension = (split(/\./,$file))[-1];
 return unless($valid{$extension});

 print "Checking file: $orig_file\n";
 my $new_wav_file   = $orig_file;
    $new_wav_file   =~ s/$extension$/wav/;
 my $new_ogg_file   = $orig_file;
    $new_ogg_file   =~ s/$extension$/ogg/;
 my $convert_to_wav =qq~mplayer "$orig_file" -ao pcm -aofile "$new_wav_file"~;
 my $convert_to_ogg = qq~oggenc -q $valid{$extension} "$new_wav_file" "$new_ogg_file"~;

 print "EXEC 1: $convert_to_wav\n";
 my $cmd = `$convert_to_wav`;
 print "EXEC 2: $convert_to_ogg\n";
    $cmd = `$convert_to_ogg`;
 print "REMOVE WAV:\n";
 unlink $new_wav_file;
 print "REMOVE MP3:\n";
 unlink $orig_file;
 print "\n\n";
}

sub get_files{
 push(@files,$File::Find::name) if(-f $_);
}# get_files
\n\n

<!--EDIT|renee|1111566395-->
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
<< >> 4 Einträge, 1 Seite



View all threads created 2005-03-22 19:56.