Mercurial > bins
diff tools/bins_addtext @ 0:a84c32f131df 1.1.29
Import vendor version
author | Peter Gervai <grin@grin.hu> |
---|---|
date | Wed, 15 Oct 2008 23:28:56 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/bins_addtext Wed Oct 15 23:28:56 2008 +0200 @@ -0,0 +1,92 @@ +#!/usr/bin/perl -w +#-*- mode: perl -*- + +sub process_file { + my ($dir, $file, $title, $desc) = @_; + chomp $desc; + #print "File: $file\n\tTitle: $title\n\tDesc: $desc\n"; + #print "\n$file\n"; + if($file eq "album") { + ($longdesc, $shortdesc, $sample) = split /\|/, $desc; + if($sample) { + $cmd_str = "bins_edit -a -m --sample \"$sample\" $dir"; + print "$cmd_str\n"; + `$cmd_str`; + } + if($shortdesc) { + $cmd_str = "bins_edit -a -m --shortdesc \"$shortdesc\" $dir"; + print "$cmd_str\n"; + `$cmd_str`; + } + if($longdesc) { + $cmd_str = "bins_edit -a -m --longdesc \"$longdesc\" $dir"; + print "$cmd_str\n"; + `$cmd_str`; + } + #print "\t$cmd_str\n"; + $cmd_str = "bins_edit -a -m --title \"$title\" $dir"; + print "$cmd_str\n"; + `$cmd_str`; + } + else { + $cmd_str = "bins_edit -m -t \"$title\" $dir/$file"; + print "$cmd_str\n"; + `$cmd_str`; + #print "\t$cmd_str\n"; + $cmd_str = "bins_edit -m -d \"$desc\" $dir/$file"; + print "$cmd_str\n"; + `$cmd_str`; + #print "\t$cmd_str\n\n"; + } +} + +$inc_file = "include_images.txt"; + +for($i=0; $i<=$#ARGV; $i++) { + $dir = $ARGV[$i]; + if($dir eq "-f" && $i<$#ARGV ) { + $i++; + $inc_file=$ARGV[$i]; + next; + } + + open(FILE, "$dir/$inc_file") or die "Could not open: $dir/$inc_file"; + + $title = ""; + $desc = ""; + $img_file = "album"; + $section = 1; + + while(<FILE>) + { + chomp; + $line=$_; + if(substr($line, 0 , 1) eq "") { + next; + } + + if(substr($line, 0 , 1) ne "#") { + process_file($dir, $img_file, $title, $desc); + $img_file = $line; + $title = ""; + $desc = ""; + $section = 1; + } + else { + if ($section == 1) { + $title = substr($line, 1); + $section++; + } + elsif ($section == 2) { + $desc .= substr($line, 1)."\n"; + } + } + + } + + if($section) { + process_file($dir, $img_file, $title, $desc); + } + + close(FILE) ; +}