atari email archive

a collection of messages sent at Atari from 1983 to 1992.

File renaming

(1 / 2)


I wrote a procedure (not exhaustively tested) which you can use to rename
files with wider output wildcard rules than those allowed by VMS's RENAME.
This procedure comes in handy when you want to insert or remove some chars
in the middle of a bunch of filenames for example. To run it:

$ @UTL$COM:WILD_RENAME [input_file_spec [output_file_spec]]

It will prompt you for missing item(s). You must have a wildcard
(either a "*" or "%") in both the input and output filespecs. It
only pays attention to the first wildcard found in either of the
filespecs for the purposes of creating a new filename. It does,
however, pay attention to all the wildcards in the input filename
for purposes of finding the file. For example:

$ WREN :== @UTL$COM:WILD_RENAME	!shortcut
$ wren abcde* abc*	!The "de" will effectively be removed
			!from all files whose names begin with
			!abcde in the current dir.
$ wren abcde%% abc*	!The "de" will be removed from all files
			!named abcdexx where xx is any 2 chars but exactly
			!2 chars.
$ wren abc*de* xyz*	!files whose name begins with abc and there's
			!a "de" somewhere after that will have the
			!"abc" replaced with an "xyz"
$ wren abc*de tvw*xyz	!sorry, it'll ignore the xyz of the output filespec
			!so it'll just change the "abc" files to "tvw" files.
$ wren old.a* new.b*	!wild card rules work for filetypes too.
$ wren abc*.def* xyz*.tvw*	!or both names and types

Note: if either the input filename or input filetype is unspecified, it
defaults to "*".

ds

Rename on the rampage

(2 / 2)


Oops. The WILD_RENAME program had a small problem which made it rename
rather wildly. I fixed it and added a third parameter which, if non-blank,
will make it just display what it would rename without actually
doing it. This lets you do a dry run to verify that it'll rename only
what you want it to.

$@utl$com:wild_rename input output [any_non-blank_string]

ds
Message 1 of 2

Sep 02, 1989