emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Charles Cave <charles_cave@optusnet.com.au>
To: emacs-orgmode@gnu.org
Subject: Creating CD contents listings in org mode
Date: Mon, 22 May 2006 22:31:33 +1000	[thread overview]
Message-ID: <4471AF25.2050704@optusnet.com.au> (raw)

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);
     }
}

             reply	other threads:[~2006-05-22 12:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-22 12:31 Charles Cave [this message]
2006-05-23  8:45 ` Creating CD contents listings in org mode Carsten Dominik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4471AF25.2050704@optusnet.com.au \
    --to=charles_cave@optusnet.com.au \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).