DAISY Pipeline: Rename files of a DAISY DTB as per section names

Original Author(s): Prashant Ranjan Verma

Overview

The files created by several DAISY authoring tools such as Obi, Save As DAISY & Pipeline have a similar prefix such as DTB, Speechgen etc. and it is difficult to guess the content of the file on the basis of file name alone. This becomes a concern when the DAISY book is used on a music player or when part of the book needs to be reproduced elsewhere.

Fileset Renamer is a useful script in The DAISY Pipeline for renaming the files of a DAISY book in a desired pattern.

Follow the steps given below to rename files of a DAISY fileset.

Steps for using Fileset Renamer in DAISY Pipeline

  1. Open DAISY Pipeline and in FILE menu select NEW > PIPELINE JOB or press the keyboard shortcut CTRL + N. The NEW JOB WIZARD will open as shown below.

    Image of Pipeline New Job Selection Wizard

  2. In the NEW JOB WIZARD select MODIFY AND IMPROVE > MULTI FORMAT > FILESET RENAMER and click NEXT button. The CONFIGURE FILESET RENAMER dialog will be displayed as shown below.

    Image of Fileset Renamer Configuration Dialog

  3. Click the BROWSE button to select the input file. The input file can be an OPF or NCC.HTML file from a DAISY 3 or DAISY 2.02 fileset respectively. In the OPEN dialog box make sure you select *.* in the FILE TYPE combo box before you browse to the folder which contains the DAISY book fileset to be renamed.

    Image of Open Dialog showing selection of file type

  4. Select an OUTPUT DIRECTORY. Click the BROWSE button and select an empty folder or create a new one to save the renamed fileset. This directory can not be the same as the input directory, or the script will abort.

  5. In the RENAMING PATTERN combo box select SEQ+LABEL.

    SEQ represents the sequential position of this file within the presentation. LABEL typically corresponds to the first heading in the file. For example if the 5th audio file in the given fileset contains recording of Chapter 3 then this file will be renamed as “05_Chapter_3” on using the SEQ +LABEL pattern.

    There are more options for renaming the files. Some of the optional patterns are given at the end of this article.

  6. In the FILE TYPES TO EXCLUDE edit box, a comma separated list of file types can be mentioned that should be excluded from the renaming process.

    Names for file types that can be used in the exclude list are: Xml File, Xhtml10 File, Dtbook File, Opf File, Smil File, Image File, Jpg File, Bmp File, Png File, Svg File, Css File, Audio File, Mp3 File, Mp2 File, Wav File. Note that some file types infer others: if you add Xml File to the exclude list, then all XML files will be excluded (Smil, Dtbook, Opf, Xhtml etc.). The default is to exclude images, CSS files and XML files, which means that the default value is Xml File, Css File and Image File.

  7. The USE FILESYSTEM SAFE NAMES checkbox when checked will use only the characters A-Z,a-z,0-9, hyphen and underscore in output filenames. This will ensure compatibility with most devices.

  8. The maximum number of characters in the output filename, excluding extension can be mentioned in the MAX FILENAME LENGTH Edit box. The default value is 60.

  9. Click FINISH to add this job and then start the process by clicking RUN in the RUN menu or press the keyboard shortcut CTRL + F1.

  10. If the renaming process is successful the last line in the MESSAGES WINDOW at the bottom of the screen will read something like “Saving the results to XX directory”.

    Image showing Job 

completed messages

    On error, this transformer will attempt to copy the fileset unrenamed to the destination. If it fails even with this, it will send a fatal message, then throw an exception and abort.

Optional patterns for renaming fileset

A renaming pattern consists of a sequence of tokens. A token is a symbol for a certain kind of information. The following table defines the available tokens.

Token meaning
labelA label of the current file - typically corresponding to the first heading in the file. This cannot always be set.
uid A unique identifier from the fileset (such as a DTB) to which the file belongs. This can be values of dc:identifier or dtb:uid metadata.
seq Represents the sequential position of this file within the presentation. If this is audio file 34 out of 100 audio files, the value will be '034'.
echo An echo of the input filename.
fixedA fixed string. The string is expressed within parenthesis; fixed(the string)
rndA random string. The length of the string is expressed within parenthesis; rnd(2), where each increment will add 4 random characters to the name.

If a renaming pattern contains several tokens, they are separated by plus signs. Pattern examples:

  • seq+label
  • uid+seq
  • fixed (dtb)+seq
  • echo
  • uid+rnd(2)
  • uid +seq+label

See also

DAISYpedia Categories: 


This page was last edited by PVerma on Friday, March 30, 2012 04:55
Text is available under the terms of the DAISY Consortium Intellectual Property Policy, Licensing, and Working Group Process.