From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Creating CD contents listings in org mode Date: Tue, 23 May 2006 10:45:19 +0200 Message-ID: <6183fb2e5805a19eb03f8ab3e976e51e@science.uva.nl> References: <4471AF25.2050704@optusnet.com.au> Mime-Version: 1.0 (Apple Message framework v623) Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FiSWN-00046U-Uu for emacs-orgmode@gnu.org; Tue, 23 May 2006 04:45:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FiSWL-00045E-SN for emacs-orgmode@gnu.org; Tue, 23 May 2006 04:45:42 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FiSWL-000453-P7 for emacs-orgmode@gnu.org; Tue, 23 May 2006 04:45:41 -0400 Received: from [146.50.4.51] (helo=imap.science.uva.nl) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FiSaW-0006d6-J3 for emacs-orgmode@gnu.org; Tue, 23 May 2006 04:50:00 -0400 In-Reply-To: <4471AF25.2050704@optusnet.com.au> 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: Charles Cave Cc: emacs-orgmode@gnu.org I like these perl programs popping up! This is why org-mode files are plain text - to allow to create the easily with external programs, and to extract information in arbitrary ways. Charles, at some point in the past you were planning to write a tutorial on how to use Org-mode for GTD. Is that still your plan? I'd love to see it. - Carsten On May 22, 2006, at 14:31, Charles Cave wrote: > 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); > } > } > > > > > > _______________________________________________ > Emacs-orgmode mailing list > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode > > -- Carsten Dominik Sterrenkundig Instituut "Anton Pannekoek" Universiteit van Amsterdam Kruislaan 403 NL-1098SJ Amsterdam phone: +31 20 525 7477