FixNames plugin for Take Command / TCC / 4NT

beta version 0.28.1     2018-01-16

Charles Dye

Purpose:

This plugin provides one new command FIXNAMES to rename filenames containing troublesome characters. By “troublesome” I mean those characters which are especially difficult to handle in TCC: percent signs, carets, and grave accents.

Installation:

To use this plugin, copy FixNames.dll to some known location on your hard drive. (If you are using the 64-bit version of Take Command, take FixNames-x64.dll instead.) Load the plugin with a PLUGIN /L command, for example:

plugin /l c:\bin\tcmd\fixnames\fixnames.dll

If you copy the .DLL file to a subdirectory named PlugIns within your Take Command program directory, it will be loaded automatically when TCC starts.

New Command:

FIXNAMES — Rename files to remove troublesome characters.

Syntax:
FIXNAMES /A /B /C /D /E /N /N:flags /P /S filespec…

/Areplace Ampersands with underscores
/Breplace Blanks (spaces) with underscores
/Creplace parentheses with underscores
/Drename Directories, not files
/Edecode =XX hexadecimal pairs
/NNot really; list items but don’t rename them
/N:flagsdisable features; flags may include:
     E: don’t display error messages
     F: don’t fix name collisions
     J: don’t recurse into junctions (only useful with /S)
     P: don’t decode %XX hexadecimal pairs
     S: don’t display summaries
/PPrompt before each
/Srecurse into Subdirectories
filespecwildcard mask to match problematic files

This command expects one or more filespecs specifying the file(s) to be renamed. Use wildcards to match the difficult characters. Note that you do not supply a “new” or replacement filename — the plugin generates replacement filenames on its own. These new names can then be changed using the regular REN command, if desired.

Only filenames containing troublesome characters will be renamed; any others will be ignored. The following characters are currently considered “troublesome”: control characters (0x01—0x1f and 0x80—0x9f), percent signs (%), carets (^), grave accents / back quotes (`), double quotes ("), and non-breaking spaces (0xa0). Trailing spaces and periods at the end of a filename are also problematic and FIXNAMES will attempt to remove them. This list may change in future releases.

When a filename contains a percent sign followed by two hexadecimal digits, the trio is treated as an encoded character; the equals sign and two following letters or digits will be replaced with a single character. If the resulting character is in the range 0x80—0x9f, it will be interpreted as Windows-1252 and the appropriate Unicode character substituted; if there is no equivalent Unicode character, an underscore will be used. You can disable this replacement with /NP. If /E is specified, the same replacement is also performed for an equals sign followed by two hex digits.

When renaming a file, FIXNAMES will check whether a file with the same name already exists. If so, the new name will be modified by appending a number before the extension to avoid the name collision. /NF disables this feature; name collisions will cause an error message, and the offending file will not be renamed.

Startup Message:

This plugin displays an informational line when it initializes. The message will be suppressed in transient or pipe shells. You can disable it for all shells by defining an environment variable named NOLOADMSG, for example:

set /e /u noloadmsg=1

Status and Licensing:

Consider this beta software. It may well have issues. Try it at your own risk. If you find bugs, you can report them in the JP Software support forum.

FixNames is currently licensed only for testing purposes. I may make binaries and source code available under some free license once I consider it ready for use.

Download:

You can download the current version of the plugin from http://prospero.unm.edu/dl/fixnames.zip or ftp://prospero.unm.edu/fixnames.zip.