home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
CHGCAS.ZIP
/
CHGCASE.CMD
Wrap
OS/2 REXX Batch file
|
1991-08-06
|
3KB
|
89 lines
/* Steve Price IBM SAA REXX Development Department, Aug. 2, 1991
** CompuServe: 70312,1612
** Internet: pricesg@gdlvm7
** Phone: (607) 752-1866
** Mail: G09/21A, IBM Corp., P.O. Box 6, Endicott NY 13760
** (C) Copyright IBM Corporation, 1991
** Program to rename files to upper or lower case.
** Lower is default.
** Will work on individual files or groups of files.
** Syntax: chgcase fileid [/Lower|/Upper]
** NOTE: HPFS supports lower-case file names, but FAT does not.
** This program will appear to work on FAT (no error messages),
** but the filenames will not change.
** NOTE: This program is not NLS enabled: it will only
** translate between uppper and lower case for the 26
** letters used in the English alphabet.
*/
Parse arg fileid '/'opt
If fileid = '' then Do
Say 'CHGCASE: Error, filename is required.'
Exit 4
end /* Do */
Select /* Decide which way we are translating. */
/* The first test will succeed for opt = '' */
/* as well as opt being any substring of LOWER */
When abbrev('LOWER', translate(opt)) then Do
input_table = xrange('A','Z')
output_table= xrange('a','z')
end /* Do */
When abbrev('UPPER', translate(opt)) then Do
input_table = xrange('a','z')
output_table= xrange('A','Z')
end /* Do */
Otherwise
Say 'CHGCASE: Error detected (unknown option).'
Say 'valid options are LOWER and UPPER. your option was "'opt'"'
Exit 8
End
/* Now we have our translate tables. */
/* Next we decide if we are doing one file, or more than one. */
If Pos('*',fileid) > 0 | Pos('?',fileid) > 0 Then Do
/* Call DIR to find all the files. We pipe the result in to */
/* a REXX queue. We create a new queue to guard against the */
/* possiblity of another process using the queue while */
/* we are using it. */
qname = Rxqueue('create')
oldq = Rxqueue('set',qname)
'@DIR' fileid '/F|RXQUEUE' qname
If rc <> 0 Then Do
Say 'CHGCASE: some problem on the DIR command, rc='rc
Exit 12
End /* Do */
Do Queued()
/* Now process each file and directoyr that DIR found for us.*/
Parse Pull oname
Parse Value Reverse(oname) With oname '\' .
oname = Reverse(oname)
if oname = '' | oname = '.' | oname = '..' then iterate
'RENAME' oname translate(oname, output_table, input_table)
If rc <> 0 Then
Say 'CHGCASE: some problem on the RENAME command for',
oname', rc=' rc
End /* do Queued() */
Call Rxqueue 'Delete',qname
End /* fileid has an * or ? in it */
Else Do /* This is the simple case of just a single file. */
'RENAME' fileid translate(fileid, output_table, input_table)
If rc <> 0 Then Do
Say 'CHGCASE: some problem on the RENAME command, rc=' rc
Exit 20
End /* Do if rc <> */
Exit