tips:docpdf2dokuwiki
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tips:docpdf2dokuwiki [2012-08-03 15:00] – audiomobster | tips:docpdf2dokuwiki [2016-06-29 14:38] (current) – old revision restored (2014-08-20 08:24) 141.65.129.207 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Import your doc and pdf files ====== | ====== Import your doc and pdf files ====== | ||
+ | |||
+ | You need the perl wiki converter installed, pdftohtml and jodconverter. | ||
Very crude yet, enhancements welcome! | Very crude yet, enhancements welcome! | ||
- | <code perl> | + | <code perl docpdf2DokuWiki.pl> |
# | # | ||
- | |||
- | # 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. | ||
- | # 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 | ||
use HTML:: | use HTML:: | ||
+ | use File:: | ||
+ | use File::Copy; | ||
+ | |||
my $wc = new HTML:: | my $wc = new HTML:: | ||
- | $txtpath | + | $path = "/home/cplus/Anleitungen"; |
- | $imgpath | + | $txtpath |
- | @docfiles | + | $imgpath |
- | @pdffiles | + | @dirs = <$path/*>; |
- | # Remove spaces and uppercase | + | foreach $dir (@dirs) { |
- | foreach $file (@docfiles) { | + | @files = < |
- | | + | foreach $file (@files) { |
- | | + | $oldfile = $file; |
- | | + | $file =~ s/ |
- | | + | $file =~ s/\-/_/g; |
- | | + | $file =~ s/ |
+ | $file =~ s/ | ||
+ | $dirname = dirname($file); | ||
+ | $basename = basename($file); | ||
+ | $basename | ||
+ | | ||
+ | rename($oldfile, | ||
+ | if ( $file=~ /docx*$/ ) { | ||
+ | system(" | ||
+ | } | ||
+ | if ( $file=~ /pdf$/ ) { | ||
+ | | ||
+ | } | ||
+ | $htmfile = $file; | ||
+ | $htmfile =~ s/\..*//; | ||
+ | $htmfile = " | ||
+ | $newfile = $file; | ||
+ | $newfile =~ s/\..*//; | ||
+ | $newfile = " | ||
+ | if ( -e $htmfile ) { | ||
+ | open (MYFILE, ">>$newfile" | ||
+ | | ||
+ | print MYFILE | ||
+ | close (MYFILE); | ||
+ | } | ||
} | } | ||
- | + | $txtdirpath=$txtpath.' | |
- | foreach $file (@pdffiles) { | + | if ( ! -e $txtdirpath) { |
- | $oldfile | + | system(" |
- | $file =~ s/\s+/_/g; | + | |
- | $file = lc $file; | + | |
- | rename($oldfile, | + | |
- | | + | |
} | } | ||
- | + | @txt = <$dirname/*.txt>; | |
- | @htmfiles | + | |
- | + | copy($txt, $txtdirpath); | |
- | foreach $file (@htmfiles) { | + | |
- | | + | |
- | | + | |
- | | + | |
- | open (MYFILE, ">> | + | |
- | | + | |
- | print MYFILE " | + | |
- | close (MYFILE); | + | |
} | } | ||
+ | | ||
+ | if ( ! -e $imgdirpath) { | ||
+ | system(" | ||
+ | } | ||
+ | @img = < | ||
+ | | ||
+ | copy($img, $imgdirpath); | ||
+ | } | ||
+ | @img = < | ||
+ | | ||
+ | copy($img, $imgdirpath); | ||
+ | } | ||
+ | } | ||
+ | system (" | ||
- | system(" | ||
- | |||
- | system(" | ||
- | system(" | ||
</ | </ |
tips/docpdf2dokuwiki.1343998859.txt.gz · Last modified: 2012-08-03 15:00 by audiomobster