1: #!/usr/bin/perl
2: use strict;
3:
4: sub making_of_list {
5:
6: my $ftp="c:/ftproot";
7: opendir (FTP, $ftp) || die $!;
8: my @file = readdir FTP;
9: close FTP;
10: my $a=0;
11: foreach (@file) {
12:
13: open (FILES, "+>>c:/docu/ftproot.txt") || die $!;
14: if ("$file[$a]" =~ /txt/i) {
15: print FILES $file[$a],"\n";
16: } elsif ("$file[$a]" =~ /doc/i) {
17: print FILES $file[$a],"\n";
18: } elsif ("$file[$a]" =~ /mpd/i) {
19: print FILES $file[$a],"\n";
20: } elsif ("$file[$a]" =~ /mta/i) {
21: print FILES $file[$a],"\n";
22: }else {
23: }
24: $a++;
25: close FILES;
26: }
27:
28: ############################################################
29:
30: sub copy_from_root {
31:
32: use File::Copy;
33: my $ftplist = "c:/docu/ftproot.txt";
34: open (FILE, $ftplist) || die $!;
35: my @disk = <FILE>;
36: chomp @disk = <FILE>;
37: $b = 0;
38: foreach (@disk) {
39: my $report = $disk[$b];
40: print $report,"\n";
41: if ("$report" =~ /^afinv/i) {
42: my $reports = $report;
43: $reports =~ s/.mta/.mpd/ig;
44: my $truth="c:/scripts/attempt/$reports";
45: my $inv="c:/invoice/$reports";
46: my $apollo="c:/reports/$reports";
47: my $daym=(localtime(time()))[3];
48: my $afis3="c:/afis3too/$daym/$reports";
49: my $source = "c:/ftproot/$report";
50: foreach my $dest ($truth, $afis3, $apollo, $inv) {
51: copy ($source, $dest);
52: }
53: unlink $source;
54: } elsif ("$report" =~ /^csinv/i) {
55: my $reports = $report;
56: $reports =~ s/.mta/.mpd/ig;
57: my $truth="c:/scripts/attempt/$reports";
58: my $inv="c:/invoice/$reports";
59: my $apollo="c:/reports/$reports";
60: my $daym=(localtime(time()))[3];
61: my $afis3="c:/afis3too/$daym/$reports";
62: my $source = "c:/ftproot/$report";
63: foreach my $dest ($truth, $afis3, $apollo, $inv) {
64: copy ($source, $dest);
65: }
66: unlink $source;
67: } elsif ("$report" =~ /^sfinv/i) {
68: my $reports = $report;
69: $reports =~ s/.mta/.mpd/ig;
70: my $truth="c:/scripts/attempt/$reports";
71: my $inv="c:/invoice/$reports";
72: my $apollo="c:/reports/$reports";
73: my $daym=(localtime(time()))[3];
74: my $afis3="c:/afis3too/$daym/$reports";
75: my $source = "c:/ftproot/$report";
76: foreach my $dest ($truth, $afis3, $apollo, $inv) {
77: copy ($source, $dest);
78: }
79: unlink $source;
80: } elsif ("$report" =~ /doc/i) {
81: my $reports = $report;
82: $reports =~ s/doc/txt/ig;
83: my $truth="c:/scripts/attempt/$reports";
84: my $apollo="c:/reports/$reports";
85: my $daym=(localtime(time()))[3];
86: my $afis3="c:/afis3too/$daym/$reports";
87: my $source = "c:/ftproot/$report";
88: foreach my $dest ($truth, $afis3, $apollo) {
89: copy ($source, $dest);
90: }
91: unlink $source;
92: } elsif ("$report" =~ /mta/i) {
93: my $reports = $report;
94: $reports =~ s/.mta/.mpd/ig;
95: my $truth="c:/scripts/attempt/$reports";
96: my $apollo="c:/reports/$reports";
97: my $daym=(localtime(time()))[3];
98: my $afis3="c:/afis3too/$daym/$reports";
99: my $source = "c:/ftproot/$report";
100: foreach my $dest ($truth, $afis3, $apollo) {
101: copy ($source, $dest);
102: }
103: unlink $source;
104: } else {
105: my $reports = $report;
106: my $truth="c:/scripts/attempt/$reports";
107: my $listing="c:/scripts/fink.txt";
108: my $apollo="c:/reports/$reports";
109: my $daym=(localtime(time()))[3];
110: my $afis3="c:/afis3too/$daym/$reports";
111: my $source = "c:/ftproot/$report";
112: foreach my $dest ($truth, $afis3, $apollo) {
113: copy ($source, $dest);
114: }
115: unlink $source;
116: }
117: my $listing="c:/scripts/fink.txt";
118: open (LST,"+>>$listing")or die "$!";
119: my $paper = sprintf("%.6s", $report);
120: my $bbat=".bat";
121: my $pap=join("",$paper,$bbat);
122: $pap =~ tr/a-z/A-Z/;
123: print LST $pap,"\n";
124: close LST;
125: $b++;
126: }
127: }
128: }
129: ############################################################
130:
131: sub make_list_for_batches {
132:
133: my $lst = "c:/scripts/fink.txt";
134:
135: open (LST, $lst) || die $!;
136: my (@array, %hash);
137: foreach (<LST>) {
138: push (@array, $_) unless (defined($hash{$_}));
139: $hash{$_} = 1;
140: };
141: close (LST);
142: open (LST, ">$lst") || die $!;
143: print LST join("", @array);
144: close (LST);
145: }
146:
147: ############################################################
148:
149: sub this_gets_a_listing_of_the_batch_files {
150:
151: my $bats="c:/reports";
152: opendir (BATS, $bats) || die $!;
153: my @bat = readdir BATS;
154: close BATS;
155: my $r=0;
156: foreach (@bat) {
157: if ("$bat[$r]" =~ /bat/i) {
158: open (STAB, "+>>c:/scripts/bats.txt") || die $!;
159: print STAB $bat[$r],"\n";
160: }
161: $r++;
162: }
163: close STAB;
164: }
165:
166: ############################################################
167:
168: sub wow {
169:
170: my $batch="c:/scripts/bats.txt";
171: my $fink = "c:/scripts/fink.txt";
172: my $wow="c:/scripts/wow.txt";
173: open (BAT, "+$batch") or die $!;
174: open (LST, "+$fink") or die $!;
175: my @batch = <BAT>;
176: my @lst = <LST>;
177: my $c = 0;
178: foreach (@lst){
179: my $sub=$lst[$c];
180: my $d=0;
181: foreach (@batch){
182: my $sub2 = $batch[$d];
183: if ("$sub2" =~ /$sub/ig){
184: open (WOW, "+>>$wow") or die $!;
185: print WOW $batch[$d];
186: print "Working...\n";
187: }$d++;
188: }$c++;
189: }
190: close BAT;
191: close LST;
192: close WOW;
193: }
194:
195: ############################################################
196:
197: sub run_the_batches {
198:
199: my $copy="c:/scripts/wow.txt";
200: open (COPY, "+$copy") || die $!;
201: my @co = <COPY>;
202: chomp @co = <COPY>;
203: my $s=0;
204: my $output = "c:/reports/$co[$s]";
205: foreach (@co) {
206: system ($output);
207: $s++;
208: }
209:
210: }
211:
212: ############################################################
213:
214: sub delete {
215:
216: my $fink = "c:/scripts/fink.txt";
217: my $bat = "c:/scripts/bats.txt";
218: my $wowo = "c:/scripts/wow.txt";
219: my $ftpr = "c:/docu/ftproot.txt";
220:
221: open (FINK, "+>$fink") || die "$!";
222: open (BAT, "+>$bat") || die "$!";
223: open (WOW, "+>$wowo") || die "$!";
224: open (FTP, "+>$ftpr") || die "$!";
225:
226: unlink <FINK>;
227: unlink <BAT>;
228: unlink <WOW>;
229: unlink <FTP>;
230:
231: }
232:
233: #
234: #
235: #
236: #
237: #
238: ############################################################
239:
240: ############################################################
241:
242:
243: print "\n\n\n";
244: print " Robco Inc. Presents : \n\n\n";
245: print " The NEW, AMAZING, INCREDIBLE ....\n\n\n";
246: print " Robco Document Rotisserie!!!!!\n\n\n";
247: print "Just RENDER it, THEN don't REMEMBER it!!!!!\n\n";
248: print " It's just that easy.\n\n\n\n\n";
249:
250: while (1) {
251:
252: my $clock = localtime;
253: print $clock,"\n";
254: print "sleeping .... ZzZzZzZzZz......\n";
255: sleep (10);
256: print "OK! OK! .... I'm awake! .... I'm awake\n";
257: ©_from_root;
258: &make_list_for_batches;
259: &this_gets_a_listing_of_the_batch_files;
260: &wow;
261: &run_the_batches;
262: &delete;
263: &making_of_list;
264: }
265:
266: # Edited by Ovid 2001/06/15
267: # Shortened title from: a program to go find documents in a file then copy
268: # them to seperate folders, delete them from the original folder, then run a
269: # batch to process the individual files with their respected batch files
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Document maintenance script
by chromatic (Archbishop) on Jun 16, 2001 at 03:53 UTC | |
|
Re: Document maintenance script
by Dominus (Parson) on Jun 19, 2001 at 12:53 UTC | |
|
Re: Document maintenance script
by CharlesClarkson (Curate) on Jun 21, 2001 at 02:14 UTC | |
by blacksmith (Hermit) on Jun 21, 2001 at 18:31 UTC | |
by CharlesClarkson (Curate) on Jun 25, 2001 at 07:41 UTC |