Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Can someone write me a simple Perl script for a few bucks? (http://www.velocityreviews.com/forums/t896428-can-someone-write-me-a-simple-perl-script-for-a-few-bucks.html)

mikeand1@comcast.net 02-04-2006 04:20 AM

Can someone write me a simple Perl script for a few bucks?
 
Can someone out there write me a little Perl script? It'd be a dead
simple program, and I can pay you for your time and trouble.

Basically all it has to do is look at the contents of a directory, and
output a text file whose exact contents would depend on the names and
numbers of files in that directory. Bonus points if it can do this for
multiple subdirectories in a directory. I'll give you the specs for the
file if you want to see it before taking on the job.

This would be done on a Windows PC (I'd be working from DOS I suppose.)


Anyone? This would probably take 10 minutes for a decent programmer to
write, I suppose, but I'll pay $50, or whatever it's worth to you,
within reasonable limits depending on how hard it is to do.

Thanks,
Mike


usenet@DavidFilmer.com 02-04-2006 04:22 AM

Re: Can someone write me a simple Perl script for a few bucks?
 
mikea...@comcast.net wrote:
> Can someone out there write me a little Perl script? It'd be a dead
> simple program, and I can pay you for your time and trouble.


http://jobs.perl.org is that way ->

This is a place where free advice is offered to people who are trying
to learn or use Perl.

--
http://DavidFilmer.com


Jürgen Exner 02-04-2006 05:46 AM

Re: Can someone write me a simple Perl script for a few bucks?
 
mikeand1@comcast.net wrote:
> Can someone out there write me a little Perl script? It'd be a dead
> simple program, and I can pay you for your time and trouble.
>
> Basically all it has to do is look at the contents of a directory,


perldoc -f opendir
perldoc -f readdir

> and
> output a text file


> perldoc -f open


> whose exact contents would depend on the names and
> numbers of files in that directory.


perldoc -f print

> Bonus points if it can do this for
> multiple subdirectories in a directory. I'll give you the specs for


perldoc -f File::Find

jue



mikeand1@comcast.net 02-04-2006 06:12 AM

Re: Can someone write me a simple Perl script for a few bucks?
 
It's a little more complicated than that:

You can assume the directory is called DirectoryName, and contains
files of only two types: .txt files, and .tif files. The directory
will contain files something like this:

FileName1.txt
FileName1.tif

FileName2.txt
FileName2.tif
FileName3.tif
FileName4.tif

FileName5.txt
FileName5.tif
FileName6.tif
FileName7.tif
FileName8.tif

There is always a .txt file associated with one or more .tif files.

For example, FileName1.txt is obviously associated with FileName1.tif.


But there are three .tif files associated with FileName2.txt:
FileName2.tif, FileName3.tif, and FileName4.tif.

And there are four .tif files associated with FileName5.txt:
FileName5.tif, FileName6.tif, FileName7.tif, and FileName8.tif

The name of a .txt file always corresponds exactly to the name of the
first .tif file associated with it (excepting for the file extension,
of course).

There can be any number of .tif files associated with a .txt file. You
can assume the .tif files associated with a .txt file are always
numbered in sequence, starting with the number of the .txt file.

However, you should assume that the number of .tif files associated
with a .txt file increases with the number of .txt files, as in my
example. The first .txt file might have five .tif files with it, the
second .txt file might have only one .tif file associated with it, and
so on.

The outputted text file should have the following format for the above
group of files:

@FULLTEXT DOC

; Record 1
@C BEGDOC# FileName1
@C ENDDOC# FileName1
@C PGCount 1
@T FileName1
@D @I\DirectoryName\
FileName1.tif

; Record 2
@C BEGDOC# FileName2
@C ENDDOC# FileName4
@C PGCount 3
@T FileName2
@D @I\DirectoryName\
FileName2.tif
FileName3.tif
FileName4.tif

; Record 3
@C BEGDOC# FileName5
@C ENDDOC# FileName8
@C PGCount 4
@T FileName5
@D @I\DirectoryName\
FileName5.tif
FileName6.tif
FileName7.tif
FileName8.tif

You can see that after BEGDOC#, you put the file name corresponding to
the first .tif file that corresponds to a .txt file, and after ENDDOC#,
you put the name of the last .tif file corresponding to that .txt file.
After PGCount, you put the number of .tif files that correspond to
that .txt file. After @T, you put the name of the .txt file (minus the
extension). And then below the @D file, you list all the .tif files
that correspond to that .txt file.

There can be any number of .txt files, sometimes quite large, and any
(nonzero) number of .tif files associated with each .txt file.

The outputted text file should be called DirectoryName.dii where
DirectoryName is the name of the directory holding the files, as above.

That's it.

I have a large number of directories to process in this manner, so if
you want to build a script that automatically searches for
subdirectories containing files like this, and creates a .dii file for
each such subdirectory, that'd be even better.


mikeand1@comcast.net 02-04-2006 06:13 AM

Re: Can someone write me a simple Perl script for a few bucks?
 
OK, I posted it there too.

Thanks,
Mike


Xicheng 02-04-2006 07:26 AM

Re: Can someone write me a simple Perl script for a few bucks?
 
mikeand1@comcast.net wrote:
> It's a little more complicated than that:
>
> You can assume the directory is called DirectoryName, and contains
> files of only two types: .txt files, and .tif files. The directory
> will contain files something like this:
>
> FileName1.txt
> FileName1.tif
>
> FileName2.txt
> FileName2.tif
> FileName3.tif
> FileName4.tif
>
> FileName5.txt
> FileName5.tif
> FileName6.tif
> FileName7.tif
> FileName8.tif
>
> There is always a .txt file associated with one or more .tif files.
>
> For example, FileName1.txt is obviously associated with FileName1.tif.
>
>
> But there are three .tif files associated with FileName2.txt:
> FileName2.tif, FileName3.tif, and FileName4.tif.
>
> And there are four .tif files associated with FileName5.txt:
> FileName5.tif, FileName6.tif, FileName7.tif, and FileName8.tif
>
> The name of a .txt file always corresponds exactly to the name of the
> first .tif file associated with it (excepting for the file extension,
> of course).
>
> There can be any number of .tif files associated with a .txt file. You
> can assume the .tif files associated with a .txt file are always
> numbered in sequence, starting with the number of the .txt file.
>
> However, you should assume that the number of .tif files associated
> with a .txt file increases with the number of .txt files, as in my
> example. The first .txt file might have five .tif files with it, the
> second .txt file might have only one .tif file associated with it, and
> so on.
>
> The outputted text file should have the following format for the above
> group of files:
>
> @FULLTEXT DOC
>
> ; Record 1
> @C BEGDOC# FileName1
> @C ENDDOC# FileName1
> @C PGCount 1
> @T FileName1
> @D @I\DirectoryName\
> FileName1.tif
>
> ; Record 2
> @C BEGDOC# FileName2
> @C ENDDOC# FileName4
> @C PGCount 3
> @T FileName2
> @D @I\DirectoryName\
> FileName2.tif
> FileName3.tif
> FileName4.tif
>
> ; Record 3
> @C BEGDOC# FileName5
> @C ENDDOC# FileName8
> @C PGCount 4
> @T FileName5
> @D @I\DirectoryName\
> FileName5.tif
> FileName6.tif
> FileName7.tif
> FileName8.tif
>
> You can see that after BEGDOC#, you put the file name corresponding to
> the first .tif file that corresponds to a .txt file, and after ENDDOC#,
> you put the name of the last .tif file corresponding to that .txt file.
> After PGCount, you put the number of .tif files that correspond to
> that .txt file. After @T, you put the name of the .txt file (minus the
> extension). And then below the @D file, you list all the .tif files
> that correspond to that .txt file.
>

#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;

my $dirname = "My_dir";
local $/='';
my $record;
print "\@FULLTEXT DOC\n";
while(<DATA>) {
my @a=();
print "; Record $.\n";
push @a,$1 while/^(.+?\.tif)$/mg;
$a[0]=~/^(\w+?)\.tif$/ and print "\@C BEGDOC# $1\n";
$a[$#a]=~/^(\w+?)\.tif$/ and print "\@C ENDDOC# $1\n";
print "\@C PGCount ",scalar@a,"\n";
/^(\w+)\.txt$/m and print "\@T $1\n";
print "\@D \@T $dirname\n";
print "$_\n" for@a ;
print "\n";
}
__DATA__
FileName1.txt
FileName1.tif

FileName2.txt
FileName2.tif
FileName3.tif
FileName4.tif

FileName5.txt
FileName5.tif
FileName6.tif
FileName7.tif

========
you can use GNU "find" to traverse your dir and subdir, and use perl to
group filenames into the above form.. you may add dirname to each
group, just use the similar ways to add into the code...
Good luck,

Xicheng

> There can be any number of .txt files, sometimes quite large, and any
> (nonzero) number of .tif files associated with each .txt file.
>
> The outputted text file should be called DirectoryName.dii where
> DirectoryName is the name of the directory holding the files, as above.
>
> That's it.
>
> I have a large number of directories to process in this manner, so if
> you want to build a script that automatically searches for
> subdirectories containing files like this, and creates a .dii file for
> each such subdirectory, that'd be even better.



mikeand1@comcast.net 02-04-2006 07:27 AM

Re: Can someone write me a simple Perl script for a few bucks?
 
BTW, anyone who wants to do this and get paid should notify me first,
so I don't get more than one person working on it.

Thanks,
Mike


Keith Keller 02-04-2006 07:28 AM

Re: Can someone write me a simple Perl script for a few bucks?
 
On 2006-02-04, mikeand1@comcast.net <mikeand1@comcast.net> wrote:

> I have a large number of directories to process in this manner, so if
> you want to build a script

^^^

If you are posting here, *you* are building the script. If you're
posting job offers, you should not be posting here. Posting to
both here and jobs.perl.org is impolite at best.

--keith

--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
see X- headers for PGP signature information


mikeand1@comcast.net 02-04-2006 07:34 AM

Re: Can someone write me a simple Perl script for a few bucks?
 
Keith Keller wrote:
> If you are posting here, *you* are building the script. If you're
> posting job offers, you should not be posting here. Posting to
> both here and jobs.perl.org is impolite at best.
>
> --keith



OK - sorry, thought someone would want to make a couple bucks, didn't
know the netiquette.

Now people are responding to me, feel like I should say something back.


mikeand1@comcast.net 02-04-2006 07:39 AM

Re: Can someone write me a simple Perl script for a few bucks?
 
Thanks - but isn't there some way to do this without having to put the
_DATA_ in each perl script file?

Each directory has a different set of files; the filenames I provided
above was only an example. I'm trying to set it up to output these
files automatically, not have to put the filenames in each script.

Also -- how do I modify that script so that it outputs to a text file,
as opposed to spitting out the text? I assume there's something like
C's printf?

Thanks,
Mike



All times are GMT. The time now is 07:15 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.