# HG changeset patch # User nml # Date 1448032997 18000 # Node ID bae199dc511f15605d157c7d32c236487bfebc7e planemo upload commit 75c510cf71217015f3f83baf61a4a54a3a1f4bfd diff -r 000000000000 -r bae199dc511f bundle_collection.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bundle_collection.pl Fri Nov 20 10:23:17 2015 -0500 @@ -0,0 +1,120 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use File::Copy; +use File::Basename; +use Getopt::Long; +use Pod::Usage; + +my ($html_file, $html_path, @args, %information, $folder); + +Getopt::Long::Configure('bundling'); +GetOptions( + 'i|input=s' => \@args, + 'h|html=s' => \$html_file, + 'p|path=s' => \$html_path + ); + +pod2usage(1) unless @args && $html_file && $html_path; + +#At this point, the output directory does not exist yet. So we have to make it +mkdir $html_path or die "Could not make directory $!"; + +#Now make a folder for all our files +my $data_folder = $html_path."/Bundled_Collection"; +mkdir $data_folder or die "Could not make directory $!"; + +#Go through each list item +foreach my $entry (@args) +{ + #Get key and value. Remove any spaces + my ($info, $file) = split /=/, $entry; + my ($name, $ext) = split /,/, $info; + $name=~s/ /_/g; + my $full_name = $name.".".$ext; + + #We store this for later to make the html file + $information{$name}{$ext}=1; + + #copy each file to its directory + + my $file_path = $data_folder."/".$full_name; + + copy($file,$file_path) or die "Could not copy $file to $file_path: $!"; +} + +#Write out the html file +open my $out, ">", $html_file or die "Could not open html file: $!"; + +my $num_keys = scalar(keys %information); +my $num_vals = scalar(@args); + +printf $out " + + + +
+ +File name | File type |
---|---|
$key | $val |