tips:docpdf2dokuwiki
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tips:docpdf2dokuwiki [2012-08-03 14:54] – created 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> |
# | # | ||
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) { | + | |
- | | + | |
- | | + | |
- | | + | |
- | print $newfile; | + | |
- | print " | + | |
- | open (MYFILE, ">> | + | |
- | | + | |
- | print MYFILE " | + | |
- | close (MYFILE); | + | |
} | } | ||
+ | | ||
+ | if ( ! -e $imgdirpath) { | ||
+ | system(" | ||
+ | } | ||
+ | @img = < | ||
+ | | ||
+ | copy($img, $imgdirpath); | ||
+ | } | ||
+ | @img = < | ||
+ | | ||
+ | copy($img, $imgdirpath); | ||
+ | } | ||
+ | } | ||
+ | system (" | ||
- | system(" | ||
- | |||
- | system(" | ||
- | system(" | ||
</ | </ |
tips/docpdf2dokuwiki.1343998487.txt.gz · Last modified: 2012-08-03 14:54 by audiomobster