subhash1198 has asked for the wisdom of the Perl Monks concerning the following question:
I have several image files in tif format. They are placed in different folders like folder IMAGES>001,IMAGES>002,IMAGES>003 etc. I have a list of BEGDOC and ENDDOC based on that i have to create a opticon load file which gives me out BEGDOC foldername,Image path and the count of child documents and parent image being marked as Y. I have a script something like this.
use strict; #USER INPUTS print "Enter the Loadfile file which contains BegDoc and EndDoc\n"; chomp(my $in = <STDIN>); print "Enter the location of the Image file\n"; chomp(my $tiffpath = <STDIN>); print "Enter the Name of the Production\n"; chomp(my $prodvolumename = <STDIN>); my $delim = ""; my $textd = "þ"; chomp($in); my $out = $in . "\.opt"; my $header = 1; open OUT,">$out" or die "Cannot Create $out\n"; open IN, "<$in" or die "Cannot open $in\n"; while (<IN>) { chomp; next if ($header++==1); my $line = $_; $line =~ s/þ//gi; my @data = split(/$delim/,$line); my $start = $data[0]; $start =~ s/þ//gi; my $end = $data[1]; $end =~ s/þ//gi; my $snum = $start; $snum =~ s/[^0-9]+//gi; my $enum = $end; $enum =~ s/[^0-9]+//gi; my $pref = $end; $pref =~ s/[0-9]+//gi; my $pages = $enum - $snum +1; my $first = 1; for (my $i = $snum; $i <= $enum; $i++) { my $number = sprintf("%0*d",length($enum),$i); #print OUT $pref . $number . "," . $pref.$number . ",$tiffpath +\\$pref$number.tif,"; print OUT $pref . $number . "," . $prodvolumename . ",$tiffpat +h\\$pref$number.tif,"; if ($first == 1) { print OUT "Y,,,$pages\n"; $first++; } else { print OUT ",,,\n"; } } } close(IN); close(OUT);
The problem is the image path is not counting the folder in its path from where the tif file coming. EX: if tif is coming from Images/001/test.tif This script outputs Images/test.tif. Could anyone please solve this ASAP?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Traverse directory backwards based on file
by kcott (Archbishop) on Mar 29, 2014 at 21:04 UTC | |
|
Re: Traverse directory backwards based on file
by kcott (Archbishop) on Mar 29, 2014 at 22:39 UTC | |
by subhash1198 (Initiate) on Mar 30, 2014 at 03:30 UTC | |
by kcott (Archbishop) on Mar 30, 2014 at 12:56 UTC | |
by subhash1198 (Initiate) on Mar 30, 2014 at 13:42 UTC | |
by kcott (Archbishop) on Mar 30, 2014 at 15:39 UTC |