[opencms-dev] FYI: importing files is easy with this script

Jeroen Habets Jeroen.Habets at framfab.nl
Mon Jan 15 10:39:47 CET 2001


Hi y'all

Because I had to import some stuff as well, I created a Perl script that
generates a manifest.xml file for you!

go to directory that contains the directory with file tree you want to
import (in example mydir). Run manigen.pl <mydir> and zip the file tree
and the output of manigen.pl. The resulting archive can be imported into
opencms after it has been copied to the export directory of opencms.


   * cd <wherever>
   * manigen.pl <mydir>  >  manifest.xml
   * zip <myarchive.zip> manifest.xml <mydir>
   * cp <myarchive.zip> <my_exportdir>

This way you can easily import whole file trees!
Jeroen

Perl source of manigen.pl:
Note: you can assign a user, group and access mask with the variables
$user,$group, and $access ;-).

--- begin ---
#!/usr/bin/perl
    eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
        if $running_under_some_shell;

require "find.pl";

print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
print "<export>\n";
print "\t<!-- Creator: manigen.pl $ARGV[0] -->\n";
print "\t<!-- Createdate: $^T -->\n";
print "\t<files>\n";

# Traverse desired filesystems
&find($ARGV[0]);

print "\t</files>\n";
print "</export>\n";

exit;

sub wanted {
        $user="Admin";
        $group="Users";
        $access=79;
        if ( $name ne "." ) {
                if (-d $_ ) {
                        print "\t\t<file>\n";
                        print
"\t\t\t<destination>$name</destination>\n";
                        print "\t\t\t<type>folder</type>\n";
                        print "\t\t\t<user>$user</user>\n";
                        print "\t\t\t<group>$group</group>\n";
                        print "\t\t\t<access>$access</access>\n";
                        print "\t\t\t<properties/>\n";
                        print "\t\t</file>\n";
                } elsif (-f $_ ) {
                        if (/\.(gif|jpg|png)$/i) {
                                $type="image";
                        } else {
                                $type="plain";
                        }
                        print "\t\t<file>\n";
                        print "\t\t\t<source>$name</source>\n";
                        print
"\t\t\t<destination>$name</destination>\n";
                        print "\t\t\t<type>$type</type>\n";
                        print "\t\t\t<user>$user</user>\n";
                        print "\t\t\t<group>$group</group>\n";
                        print "\t\t\t<access>$access</access>\n";
                        print "\t\t\t<properties/>\n";
                        print "\t\t</file>\n";
                }
        }
}
--- end ---

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20010115/185fafe5/attachment.htm>


More information about the opencms-dev mailing list