RENAME Version 3.5 Gene Pizzetta July 1, 1990 RENAME, originally written by Richard Conn, renames files from the command line or interactively, using ambiguous filenames and CP/M-style or MS-DOS-style syntax. Options allow prompting before each file is renamed, renaming of system files, and erasure of existing files without prompting. USAGE: Old style (newname=oldname): RENAME {dir:}afn.aft=afn.aft{,{dir:}afn.aft=afn.aft{,...}} {{/}options} New style (oldname newname): RENAME {dir:}afn.aft afn.aft{,{dir:}afn.aft afn.aft{,...}} {{/}options} Interactive control mode (oldname): RENAME {dir:}afn.aft{,{dir:}afn.aft{,...}} {{/}options} All three forms may be mixed within a command line. If no DIR or DU specification is given, the current drive/user is assumed. Multiple file list elements must be separated by commas without intervening spaces. OPTIONS: A leading slash is optional. E Erase existing files without prompting. If RENAME finds that the renamed file will have the same name as an existing file, it normally asks if the existing file should be erased. Using this option will cause such files to be erased without prompting. I Inspect mode. Each matching filename is displayed and the user is prompted. A response of "Y" will cause the file to be renamed. Entering "Q" or ^C will exit the program. Any other response will skip the file and then prompt for the next matching filename. S Toggle inclusion of system files. Whether RENAME recognizes system files by default is determined by a configuration byte in the first record of the COM file preceded by the ASCII string "SYSFILES>". If the byte is zero, system files are ignored; if it is non-zero, system files are erased. The default condition is reversed by this option. As distributed, the default is to exclude system files. If only one, possibly ambiguous, filename is given, RENAME will enter Control mode. Each matching filename will be displayed individually and the user will be asked to specify the new name for that file. Pressing only a carriage return will skip renaming of the currently displayed file. Entering ^C will abort the program. If the ZCPR3 quiet flag is set, all screen output is suppressed, except error messages and required prompts. If the E option is not given and RENAME finds an existing file with the same name, for instance, the user is prompted for permission to erase the file even if the quiet flag is on. Inspect and Control modes prompt normally at all times. ZEX input is turned off while RENAME is running. On exit the program error flag is set to 10 (source file not found) if no files are renamed, unless the program is aborted at a prompt with "Q" or ^C. In addition, the number of files renamed is entered into ZCPR3 register 0 (up to a maximum of 255). If an invalid option is given, the program error flag is set to 19 and the error handler is invoked. READ/ONLY CAUTION: RENAME renames read/only files without warning. In addition, if an existing file is read/only, it will also be erased without warning if the E option is used or if the "Erase?" prompt is answered with a "Y". This "feature" should probably be removed. It would be better if RENAME acted like ERASE, prompting "Read/Only, Rename?" or "Read/Only, Erase?" before doing anything. An "R" option could be added to allow bypassing the questions. Anyone interested in taking on this mod? HISTORY: Version 3.5 -- July 1, 1990 -- Gene Pizzetta Changed filename display to "oldfile to newfile" instead of the strange "newfile from oldfile". Added configuration byte after ASCII string 'SYSFILES>' to chose whether to include system files by default (non-zero) or exclude them by default (0). S option now toggles the default meaning (it's current action is shown by the usage screen. Now filters high bit of filenames for terminals that display special characters that way. At the suggestion of Howard Goldstein, RENAME no longer signs on with its load address and version number; these are displayed only on the usage screen. Restored Q (quit) as a valid response to an rename or erase query, but ^C still works. Display has been made even more compact than last version. Many of these changes are to make the RENAME interface very similar to the RCP version. Sets program error flag to 10 if a matching filename is not found. If an invalid option is given, the program error flag is set to 19 and the error handler is invoked. ZEX input is suspended during execution of RENAME. The number of files renamed (up to 255) is placed in ZCPR3 register 0. Now obeys ZCPR3 quiet flag, except when in inspect or control mode, or when a prompt is necessary. Removed Wheel byte protection for E and S options. Version 3.4 -- March 31, 1990 -- Gene Pizzetta Modified for more compact display, usually a single line for each file renamed. ^C aborts at any prompt. Version 3.3A -- December 30, 1987 -- Bruce Morgen Strip high bit from EFCB program name characters. "E" and "S" options require Wheel byte set; help message reflects this. Version 3.3 -- December 19, 1987 -- Bruce Morgen Help message now reflects actual COM file name used, PPIP- style dual syntax implemented (as requested by Ken Taschner). This required some rather tricky parsing to support the single-filespec syntax "afn.typ [/]c", so while I was at it I made control mode mandatory and automatic for single-filespec elements and eliminated the C option letter altogether (as Rick says: "It only makes sense"...). In order support this single-filespec mode when such an element is the last (or only) one in a RENAME command line, the second file-spec in the last (or only) command is tested if the MS-DOS syntax is detected. If that second filespec starts with a "/" or includes only valid option letters (and no more characters than the number of valid option letters) it is assumed to be an option specifier rather than a rename-to filespec. Following Howard Goldstein's (LX17 & 18) lead, filespec-to-FCB parsing calls the Z33 CCP if it's available. A Z80, HD64180, NSC800 or (someday?) Z280 CPU now is required. Version 3.2 -- August 25, 1987 -- Jay Sage Changed to allow a leading slash before an option to make program consistent with a number of other Z programs (this was supposed to happen, but there was a bug in the code). Put data into a DSEG. Made header indicate load address. Version 3.1 -- April 12, 1987 -- Jay Sage Took idea of Rick Charnes and implemented it as an option so that one does not have to have two versions of the program. The option is 'E'. Also updated code to ZCPR33 type-3 environment to allow linking RENAME for execution in high memory if desired. Version 3.0a -- April 9, 1987 -- Rick Charnes I have modified this source code slightly so that if you try to rename FILE1 to FILE2 and FILE2 already exists, the program will NOT ask you if you are sure you want to delete FILE2. It just goes ahead and deletes the darn thing and renames FILE1. I had an application for it, studied and little and ... it works. Be careful, though. This is a special use program, and NOT for everyday use. I found an alias in which I needed it. Version 3.0 -- May 18, 1984 -- Richard Conn Version 2.0 -- January 16, 1983 -- Richard Conn Version 1.4 -- January 6, 1983 -- Richard Conn Version 1.3 -- December 7, 1982 -- Richard Conn Version 1.2 -- November 10, 1982 -- Richard Conn Version 1.1 -- October 26, 1981 -- Richard Conn RENAME.ASM