tips:docpdf2dokuwiki
This is an old revision of the document!
Import your doc and pdf files
Very crude yet, enhancements welcome!
#!/usr/bin/perl # Copyright (C) 2012 audiomobster (audiomobster at gmail dot com) # # docpdf2Dokuwiki is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 2 of the License, # or (at your option) any later version. # docpdf2DokuWiki is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA use HTML::WikiConverter; my $wc = new HTML::WikiConverter( dialect => 'DokuWiki' ); $txtpath = "/var/www/dokuwiki/data/pages/anleitungen"; $imgpath = "/var/www/dokuwiki/data/media/anleitungen"; @docfiles = </var/www/dokuwiki/data/pages/anleitungen/*.doc*>; @pdffiles = </var/www/dokuwiki/data/pages/anleitungen/*.pdf>; # Remove spaces and uppercase foreach $file (@docfiles) { $oldfile = $file; $file =~ s/\s+/_/g; $file = lc $file; rename($oldfile,$file); system("unoconv", "--format=html", "$file"); } foreach $file (@pdffiles) { $oldfile = $file; $file =~ s/\s+/_/g; $file = lc $file; rename($oldfile,$file); system("pdftohtml", "$file"); } @htmfiles = </var/www/dokuwiki/data/pages/anleitungen/*.html>; foreach $file (@htmfiles) { $newfile = $file; $newfile =~ s/\..*//; $newfile = "$newfile.txt"; open (MYFILE, ">>$newfile"); $input = $wc->html2wiki( file => $file ); print MYFILE "$input"; close (MYFILE); } system("chown", "-R", "www-data:www-data", "$path"); system("cp", "$txtpath/*.png", "$imgpath"); system("cp", "$txtpath/*.jpg", "$imgpath");
tips/docpdf2dokuwiki.1343998859.txt.gz · Last modified: 2012-08-03 15:00 by audiomobster