Glindra
Documentation Index Download
Command Line File Handling and ASCII Tools

Cleaning Up Filenames

Filename Cleanup Options

Options
-safe
  • Maps leading dashes (hyphens) to underscores.
  • Collapses spaces.
  • Maps problematic characters like *?:[]"<>|(){} to underscore.
-portable Performs the same cleanup operations as -safe, and additionally:
  • Maps all 8-bit characters from the upper half of the Latin 1 alphabet to reasonable 7-bit fallback characters.
  • Maps the single quote characters '`´ to underscore.
-lower
-upper
-title
Converts the filenames to lower, UPPER, or Title Case.
-nospace Maps all spaces to underscore.
-nodash Maps all dashes (hyphens) to underscore.

These options can be specified with the cop and rena commands, and are used to clean up filenames. They would typically be used with a wildcard input file specification.

None of these options are on by default, so these transformations will not be carried out unless you explicitly ask for them.

Example
> rena '*.*' -lower -portable
Changes all filenames in the directory to lower case, and converts national letters and characters that are likely to cause problems on some platforms.
Example
> cop '*.*' '/export/*.*' -nospace
Copies files and makes sure that the output filenames do not contain any spaces or any of the most problematic characters.

-safe

The -safe option makes a basic cleanup of the filenames, as follows:


If you specify either of the -nospace or -nodash options, -safe is enabled by default. If you do not want this, you can disable it again with -nosafe

-portable

Performs the same transformations as the -safe option, and additionally maps all 8-bit characters from the upper half of the Latin 1 alphabet to reasonable 7-bit fallback characters.

The following character map is used:

'\000\001\002\003\004\005\006\a\010\t\n\v\f\r\016\017\020' -> '_'
'\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\177' -> '_'
'\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217' -> '_'
'\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237' -> '_'

'/:*?[]<>|(){}=' -> '_'

'\042' -> '_' // double quote
'\134' -> '_' // backslash

'\240' -> ' ' // non-breaking space
'\255' -> '-' // soft hyphen

'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞß' ->
'AAAAAAACEEEEIIIIDNOOOOO_OUUUUYTs'

'àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ' ->
'aaaaaaaceeeeiiiidnooooo_ouuuuyty'

'¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿×÷' ->
'_cL_Y___ca__R___23_u___10_______'

'`' -> '_'
'\047' -> '_' // single quote


Note: Filenames that contain characters from the upper half of the 8-bit ASCII alphabet work as expected under Windows. Under Linux, however, they do not, as each character that is greater than 127 appears to have been mapped to two characters by the filesystem.

If you have files under Windows with national letters in the names, and plan to copy them to Linux, you should make the names portable before moving them.

-lower
-upper
-title

The option -lower converts the filenames to lower case, and -upper converts them to upper case.

Both the English letters A-Z and national letters in the 8-bit Latin 1 (ISO-8859-1) alphabet are converted. The -lower option corresponds to the following character map:

"ABCDEFGHIJKLMNOPQRSTUVWXYZ" -> 
"abcdefghijklmnopqrstuvwxyz"

"ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ" ->
"àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ"


The option -title converts to "Title Case", which means that the first letter in each word is in upper case, and all other letters are in lower case.

The definition of what constitutes a "word" is very straight-forward: a word may consist of letters (including the national ones) and digits, and all other characters count as delimiters.

-nospace

Maps all space characters to underscores.

If you specify the -nospace option, -safe is enabled by default. If you do not want this, you can disable it again with -nosafe

The -safe option causes any leading, trailing, or multiple spaces in the filename are collapsed first, before the remaining spaces are mapped to underscores.

-nodash

Maps all dashes ("-") to underscore. Both leading dashes and dashes that appear inside the filename are mapped.

If you specify the -nodash option, -safe is enabled by default. If you do not want this, you can disable it again with -nosafe