i want to find files in a directory that can have multiple dots. like
Could not open 'Streams/Allegro_FUNNY_A_00_HD2_10.4.trp'
Could not open 'Streams/Allegro_FUNNY_B_00_HD2_10.4.ts'
Could not open 'Streams/Allegro_POC_CAVLC_00_5x6_10.3.ts'
Could not open 'Streams/C40UDTA.b.trp'
i could parse all other streams well but couldnt open the onces that had more than one dot.can any one correct my regex pattern? -
if(/\w+\...(dts|ts|trp|mpg|TRP)/)
-
9 3783 @kanishka1213
Well, I changed your regex to be: -
/\w+.*(dts|ts|trp|mpg|TRP)/
-
That matched (as did yours), so I am not sure what is going on. You need to share the rest of your code so we can see what's going on. The errors you gave were errors opening the files, not matching. Please provide the rest of your code so we may see what is happening.
Regards,
Jeff
-
#!/perl/bin/perl
-
-
use CGI qw(:standard);
-
use CGI::Carp qw(fatalsToBrowser);
-
use File::Basename;
-
use File::Find;
-
print header;
-
-
my @unparsed_files;
-
my $parser_tool_dir="C:/Program Files/Manzanita Systems/MP2TSA 3";
-
my $dir="F:";
-
-
my ($stream_name,$stream_loc,$htmlstream,$stream,$txtstream,$docstream);
-
my $count_present=0;
-
my $count_absent=0;
-
my $count_total=0;
-
-
find(\&edits,$dir);
-
-
sub edits
-
{
-
#Finds files with following extensions
-
if(/\w+\.(dts|ts|trp|mpg|TRP)/)
-
{
-
$count_total++; #count the number of files found
-
$stream_name=$_;
-
-
#name of stream
-
$stream_loc=$File::Find::name; #path of stream
-
-
my($stream_name, $stream_loc) = fileparse($stream_loc);
-
-
$stream_name=~ s/\..*//; #stripping off the stream extension
-
$htmlstream=$stream_loc.$stream_name.".html"; #appending html extsion
-
$txtstream=$stream_loc.$stream_name.".txt";
-
$docstream=$stream_loc.$stream_name.".doc";
-
if((-e $htmlstream)||(-e $txtstream)|| (-e $docstream))
-
{
-
$count_present++; #streams are present
-
}
-
else
-
{
-
$stream=$File::Find::name;
-
$count_absent++; #streams are absent
-
push(@unparsed_files,$stream);
-
}
-
}
-
}
-
-
my ($stream_file,$html_file);
-
-
find(\&analyze,$parser_tool_dir);
-
sub analyze
-
{
-
if($_ eq 'mp2tsa.exe')
-
{
-
foreach $stream_file(@unparsed_files)
-
{
-
$html_file=$stream_file;
-
$html_file=~ s/\..*//; #stripping off extension
-
$html_file=$html_file.".html";
-
my $status = system("mp2tsa.exe -o $html_file $stream_file");
-
}
-
}
-
}
-
print "<BR>Scanning Directory: $dir";
-
print "<BR>Total Streams Scanned: $count_total";
-
print "<BR>Parsed Streams Found : $count_present";
-
print "<BR>Unparsed Streams Found: $count_absent";
-
the multiple dots seem to have nothing to do your problem. It appears you are trying to match certain file extensions so you should anchor the regexp to the end of the string: - if(/\.(dts|ts|trp|mpg|TRP)$/)
The error "Could not open" appears to be coming from the system() call and not anything to do with perl.
@KevinADC
See, that's why I wanted to see the code, because a regex would not cause an open failure message.
I agree with Kevin, whatever that program is, that is causing the issue. It might be path related or permissions, so look into that.
Regards,
Jeff
yes. i also think the same.
but when i try to on the normal windows command line the same call on those files that couldnt open , they open also, get analysed and their relative html is also produced.
when i works fine wiht windows cmd line. i dnt understand y the same command doesnt work when embedded as a system call in perl program.
and u know what not all files are giving this error.
some of them run and some of them gives error.
strange !!!!!!!!
Could not open '2.mpg'
Could not open '2.mpg'
Could not open 'lipsync/64QAM_t0508-old3.trp'
Could not open 'lipsync/64QAM_t0508-old3.trp'
Could not open 'lipsync/64QAM_t0508-old4.trp'
Could not open 'lipsync/64QAM_t0508-old4.trp'
Could not open 'lipsync/64QAM_t0508-old5.trp'
Could not open 'lipsync/64QAM_t0508-old5.trp'
Could not open 'lipsync/64QAM_t0508-old6.trp'
Could not open 'lipsync/64QAM_t0508-old6.trp'
Could not open 'lipsync/Lipsync_TestStreams/64QAM_lipsync480i.trp'
Could not open 'lipsync/Lipsync_TestStreams/64QAM_lipsync480i.trp'
Could not open 'lipsync/Lipsync_TestStreams/64QAM_lipsync480p.trp'
Could not open 'lipsync/Lipsync_TestStreams/64QAM_lipsync480p.trp'
Could not open 'lipsync/Lipsync_TestStreams/64QAM_lipsync720p.trp'
Could not open 'lipsync/Lipsync_TestStreams/64QAM_lipsync720p.trp'
Could not open 'lipsync/Lipsync_TestStreams/LIPSYNC1080i.TRP'
Could not open 'lipsync/Lipsync_TestStreams/LIPSYNC1080i.TRP'
Could not open 'lipsync/Lipsync_TestStreams/LIPSYNC480p.TRP'
Could not open 'lipsync/Lipsync_TestStreams/LIPSYNC480p.TRP'
Could not open 'lipsync/Lipsync_TestStreams/LIPSYNC720p.TRP'
Could not open 'lipsync/Lipsync_TestStreams/LIPSYNC720p.TRP'
Could not open '204.mpg'
Could not open '204.mpg'
Could not open 'Streams/2_dialnormswp..trp'
Could not open 'Streams/2_dialnormswp..trp'
Could not open 'Streams/2_dvblevel_ddp..trp'
Could not open 'Streams/2_dvblevel_ddp..trp'
Could not open 'Streams/2_k5compress..trp'
Could not open 'Streams/2_k5compress..trp'
Could not open 'Streams/2_ref997..trp'
Could not open 'Streams/2_ref997..trp'
Could not open 'Streams/acmod1_0..trp'
@kanishka1213
Again, is it a path issue? Where is the script sitting in relation to these paths? From what I see, it would have to be in the parent directory and all these would have to be subdirectories of that parent. You may want to consider using absolute paths to avoid this issue.
Regards,
Jeff
Thanks Jeff,
i noticed the same. i copied some of the files that were in error list in one folder in c drive and it parsed all files perfectly. so the issue is when the depth of the folder gets larger the tool is not able to find it . c the folder depth.
"F:\Audio\Audio\lipsync-sharlik\new lipsync\Lipsync_TestStreams\unparsedfile.trp". so you mean to say i should use absolute paths.
but i scan entire F: drive as u see in the code. so i just named dir path as "F:".. and the path of the stream is
"F:/Audio/Dolby DD+/DD+ Streams/acmodswp.trp" is this not absolute path? m sorry my concepts are not so clear regarding this..
thanks for the real quick answer
No pain to analyze the problem any more. i got the solution. its works fine now. thanks Jeff and Kevin again. I really appreciate your help.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: John Smith |
last post by:
Hello,
I have a rather odd question. My company is an all java/oracle shop.
We do everything is Java... no matter what it is... parsing of text
files, messaging, gui you name it. My question...
|
by: Premshree Pillai |
last post by:
Hello,
I recently wrote a Perl version of pyAlbum.py -- a
Python script to create an image album from a given
directory -- plAlbum.pl .
It made me realize how easy-to-use Python is.
...
|
by: Xah Lee |
last post by:
# -*- coding: utf-8 -*-
# Python
suppose you want to walk into a directory, say, to apply a string
replacement to all html files. The os.path.walk() rises for the
occasion.
© import os
©...
|
by: Xah Lee |
last post by:
suppose you want to do find & replace of string of all files in a
directory.
here's the code:
©# -*- coding: utf-8 -*-
©# Python
©
©import os,sys
©
©mydir= '/Users/t/web'
|
by: Kirt Loki Dankmyer |
last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile
it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of
different switches, but I can't get it to compile....
|
by: shruti |
last post by:
hiii all
I'm tryin to call a perl script from a C program in following 2 ways-
1.By callin system function.
But there's some problem because the system function is not able to
executeany...
|
by: 8anos |
last post by:
Hello,
I am new at the community and newbie at programming :)
As you may know rapidshare provides a perl script for linux, to upload files at their servers.
You can find the original scripts at...
|
by: KevinADC |
last post by:
Note: You may skip to the end of the article if all you want is the perl code.
Introduction
Uploading files from a local computer to a remote web server has many useful purposes, the most...
|
by: happyse27 |
last post by:
Hi All,
I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
|
by: KevinADC |
last post by:
Note: You may skip to the end of the article if all you want is the perl code.
Introduction
Many websites have a form or a link you can use to download a file. You click a form button or click...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |