123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #!/usr/bin/perl
- use strict;
- use warnings;
- use POSIX qw/strftime/;
- my $outputfile = "/home/swflint/org/index.org";
- my $date = strftime "<%Y-%m-%d %a %H:%M>", localtime;
- my $fileHeader = <<EOF;
- #+Title: Org File Index
- #+AUTHOR: Sam Flint
- #+EMAIL: swflint\@flintfam.org
- #+DATE: $date
- #+INFOJS_OPT: view:info toc:nil path:http://flintfam.org/org-info.js
- #+OPTIONS: toc:nil H:5 ':t *:t d:nil stat:nil todo:nil
- #+LATEX_CLASS_OPTIONS: [10pt,twocolumn]
- #+LATEX_HEADER: \\usepackage[landscape,margin=0.125 in]{geometry}
- #+LATEX_HEADER: \\pagestyle{empty}
- * Org
- EOF
- open(my $output, ">", $outputfile) or die "Unable to open \"$outputfile\" the output file, $!";
- print $output $fileHeader;
- opendir(my $directory, "/home/swflint/org/")
- or die "Can't open the directory: $!";
- my @directories;
- while (my $file = readdir $directory) {
- if ($file =~ m/^\..*/) {
- next;
- } elsif (-d "/home/swflint/org/$file") {
- push @directories, $file;
- } elsif ($file =~ m/.*\.org$/) {
- (my $linkName = $file) =~ s/\.[^.]+$//;
- $linkName =~ s/-/ /g;
- $linkName =~ s/\b(\w)/\U$1/g;
- print $output " - [[file:~/org/$file][$linkName]]\n"
- } else {
- next;
- }
- }
- closedir $directory;
- foreach (sort @directories) {
- my $newDir = $_;
- if ($newDir =~ "auto" or $newDir =~ "data") {
- next;
- }
- opendir(my $theDirectory, "/home/swflint/org/$newDir/")
- or die "Can't open directory: $!";
- my $fancyDir = $newDir;
- $fancyDir =~ s/-/ /g;
- $fancyDir =~ s/\b(\w)/\U$1/g;
- print $output "\n** Org: $fancyDir\n\n";
- print $output " - [[file:~/org/$newDir/][$fancyDir]]\n";
- while (my $file = readdir $theDirectory) {
- if ($file =~ m/^\..*/
- or -d "/home/swflint/org/$newDir/$file") {
- next;
- } elsif ($file =~ m/.*\.org$/) {
- (my $linkName = $file) =~ s/\.[^.]+$//;
- $linkName =~ s/-/ /g;
- $linkName =~ s/\b(\w)/\U$1/g;
- print $output " - [[file:~/org/$newDir/$file][$linkName]]\n";
- } else {
- next;
- }
- }
- }
- close $output;
|