#!/usr/bin/perl # makenotes.pl A text splitting tool for iPod Notes # (C) 2008 Matthijs Dalhuijsen (GPL) local $|=1; unless (@ARGV) { print "makenotes -- formats text documents for usage on iPod\n"; print "Usage: $0 \n"; exit(1); } foreach my $file (@ARGV) { if (-f $file) { print "$file exists\n"; &chopfile($file); } else { print "$file not found\n"; } } sub chopfile { my $f = shift; open(F,$f); my @txt = split(//,join("",)); print "processing $f\n"; print "Please give a title for this book\n> "; my $title = ; chomp($title); print "creating dir and splitting file into subfiles in 3 seconds\n"; sleep(1); print "2\n"; sleep(1); print "1\n"; sleep(1); mkdir($title); chdir($title); my $i = 0; open(IF,">".$title."_".$i.".txt"); for (my $x = 0; $x < @txt; $x++) { print IF $txt[$x]; if ($x % 3800 == 0) { print IF "$i $title"; print IF "prev (".($i-1).") "; print IF "prev (".($i+1).") "; print IF "

"; $i++; open(IF,">".$title."_".$i.".txt"); print $title."_".$i."\n"; } } }