From mboxrd@z Thu Jan 1 00:00:00 1970 From: Charles Cave Subject: Creating CD contents listings in org mode Date: Mon, 22 May 2006 22:31:33 +1000 Message-ID: <4471AF25.2050704@optusnet.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Fi9aL-0000kX-LT for emacs-orgmode@gnu.org; Mon, 22 May 2006 08:32:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Fi9aD-0000eO-LA for emacs-orgmode@gnu.org; Mon, 22 May 2006 08:32:32 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fi9aD-0000eD-FO for emacs-orgmode@gnu.org; Mon, 22 May 2006 08:32:25 -0400 Received: from [211.29.133.158] (helo=mail21.syd.optusnet.com.au) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.52) id 1Fi9e4-0006DA-6W for emacs-orgmode@gnu.org; Mon, 22 May 2006 08:36:26 -0400 Received: from [127.0.0.1] (c211-30-18-75.thorn1.nsw.optusnet.com.au [211.30.18.75]) (authenticated sender charles_cave) by mail21.syd.optusnet.com.au (8.12.11/8.12.11) with ESMTP id k4MCVYVa008154 for ; Mon, 22 May 2006 22:31:36 +1000 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org I used to use Treepad on Windows (www.treepad.com) and wrote a Perl module to read and write Treepad Files. These were plain text but had extra information to define each node in the tree. Now I use ORG mode for my outlining requirements. Today I adapted a program to create a listing of the contents of a CD-ROM. The program is written in Perl (not Lisp!). I use Windows, and my CD-ROM drive is F: I write a unique number on each CD, for example, C039 To catalogue the disk, I run the command perl cdcat.pl C039.org F: Now I can view the file C039.org with Emacs and expand/collapse the directory names. Sample output: * f: f: ** Australian Piano Concertos f:/Australian Piano Concertos 01 Piano Concert Movt 1 - Ross Edwards.mp3 (6884786) 02 Piano Concerto Movt 2 - Ross Edwards.mp3 (10772642) 03 Piano Concerto Movt 3 - Ross Edwards.mp3 (4604168) 07 Piano Concerto - Peter Sculthorpe.mp3 (26613776) Australian Piano Concertos playlist.m3u (746) ** Sun Music f:/Sun Music 01 Memento Mori - Peter Sculthorpe.mp3 (20459686) 02 Sun Song - Peter Sculthorpe.mp3 (8521866) 03 Sun Music 1 - Peter Sculthorpe.mp3 (14595318) 04 Sun Music 2 - Peter Sculthorpe.mp3 (8466152) 05 Sun Music 3 - Peter Sculthorpe.mp3 (17877436) 06 Sun Music 4 - Peter Sculthorpe.mp3 (12673498) 07 From Uluru - Peter Sculthorpe.mp3 (5337404) Sun Music playlist.m3u (584) # Save the remained of the message as a file cdcat.pl # cdcat.pl Modified on 29th April 2005 use strict; use warnings; # parse a directory structure to create an Emacs org mode file # with a list of files against each node. my $outfile = shift; my $root = shift; # start directory for searching, a CD drive: G: my $info = ""; # the catalogue data being prepared defined($outfile) or $outfile = "cd.org"; defined($root) or die "Syntax is cdcat cdlabel CDdrive\n"; open (my $fv, ">", $outfile) or die "Cannot create $outfile\n"; my $level = 0; parse_dir($root, $level, $root); print $fv $info; close($fv); print "Analysis of $root written to $outfile\n"; ############### sub parse_dir { ############### my $dir = shift; my $level = shift; my $fullpath = shift; my @dirlist = (); my $filelist = ""; chdir($fullpath) or die "chdir to $fullpath failed\n"; opendir(my $dirfv, ".") or die "Cannot open . in $dir\n"; while (my $file = readdir($dirfv)) { if ( -f $file ) { my $size = -s $file; $filelist .= " $file ($size)\n"; } next if ($file eq "."); next if ($file eq ".."); push (@dirlist, $file) if -d $file; } $info .= '*' x ( $level + 1 ); $info .= " $dir\n$fullpath\n$filelist"; foreach my $subdir (@dirlist) { parse_dir($subdir, $level + 1, $fullpath."/".$subdir); } }