#!/usr/bin/perl # #NAME # abcsplit - extract ABC tunes from files. # #SYNOPSIS # abcsplit [file | URL] .. # #DESCRIPTION # This program reads thru its input, looking for ABC music. When it finds a # chunk of music, it creates a file derived from the title, and writes the # music to the file. # # Input is from STDIN if there are no command-line URLs or files. If there # are things named on the command line, we will first attempt to open them # as local files, and if that fails, we then try to open them as URLs. At # present, only http:// URLs work. # # If there is already a file by the given name, we add '_' and a number to # the name. # # We recognize a tune when we encounter an X: or a T: line. We will generate # an X:0 line for tunes that lacked an X: line. A tune ends with the first # blank line (and a line that contains spaces and/or tabs is considered a # blank line). # #REQUIRES # The following modules are needed for web access. They should be in the # same place that you found this script. # push @INC,"$ENV{HOME}/sh",'sh'; require "URLopen.pm"; # Parses URL and returns file handle. require "HTTPcon.pm"; # Makes HTTP connection, sends GET. require "HTMLdir.pm"; # Produces HTML listing of directory. require "outtune.pm"; # Produce output tune file. require "Backup.pm"; # For moving files to backup name # #OPTIONS # Options are args that start with '-' or '+', which disable or enable some # feature, respectively. The options are: # # +N # Number to append to the title to get the filename. If the tune's title # is "Foo Bar", the default file name will be FooBar.abc, but with the # +N5 option, it will be FooBar_5.abc. With -O, the number will be # incremented if the file already exists. # # +O # Overwrite existing files. If there are two tunes with the same title, # the second will wipe out the first. # -O # Don't overwrite existing files (default). Instead, '_' and a number are # added to the tune name, and a new file named for the tune is created. # Default. # # +RJ # Special kludge for Roaring Jelly sets: The tunes are examined for the # classification id numbers (R-78, J-42, ...), and this id is prepended # to the file name. # # +S