home *** CD-ROM | disk | FTP | other *** search
- /* equalize.rexx -- a utility for Archie by Christian '<CB>' Balzer
-
- -- _ _
- / / | \ \ <CB> aka Christian Balzer - The Software Brewery -
- < < |-< > UUCP: decwrl!frambo.dec.com!cb OR cb@frambo.dec.com
- \ \_ |_/ / CIS : 71001,210 (be brief!) | Phone: +49 6150 4151 (CET!)
- ------------ Mail: Im Wingertsberg 45, D-6108 Weiterstadt, F.R.G.
-
- Usage: [rx] equalize SOURCE DESTINATION [-options]
-
- SOURCE and DESTINATION are valid AmigaDOS path's WITHOUT trailing
- slashes '/'.
- Valid options are: -p This option will only print the differing
- filenames, but not delete them. Use it to
- see if you aren't about to destroy your work!
-
- Equalize will scan all files at SOURCE and it's subdirectories and
- compare them to the files at DESTINATION and the corresponding
- subdirectories. ALL files at DESTINATION that can't be found in
- SOURCE will be DELETED!!! This goes for directory trees, too!!!
-
- WARNING!!! Use this beast only when you know what you're doing! :-)
-
- BTW, the name of this utility wasn't inspired by the TV series
- "The Equalizer". Or was it? :-)
-
- In this version, filenames or directories containing blanks
- (like "My Dir:My File"), are NOT supported! */
-
- /* This is Public Domain, read the source and learn */
-
- say 'Equalize 1.2 (13-Jan-88) by <CB>'
-
- /* open the Rexx support library */
-
- if ~show('L',"rexxsupport.library") then do
- if addlib('rexxsupport.library',0,-30,0) then
- say 'added rexxsupport.library'
- else do;
- say 'support library not available'
- exit 10
- end
- end
-
- address command
- call pragma 'priority',-1
-
- arg rein
-
- /* The parser */
- copt = 'clone'
-
- if words(rein) < 2 then do
- say 'Come on, gimme a SOURCE *AND* a DESTINATION path'
- say 'Ya better try again... Bye!'
- exit 10
- end
-
-
- root = subword(rein,1,1)
- dest = subword(rein,2,1)
- dstat = 1
-
- if ~ exists(root) then do
- say 'Source not found'
- say 'Exiting... Check your parameters'
- exit 10
- end
-
- if ~ exists(dest) then do
- say 'Destination not found'
- say 'Exiting... Check your parameters'
- exit 15
- end
-
- if words(rein) > 2 then do
- if subword(rein,3,1) = '-P' then
- dstat = 0
- end
-
- if right(root,1) ~= ':' then
- root = root || '/'
- if root = '/' then root = ''
-
- if right(dest,1) ~= ':' then
- dest = dest || '/'
- if dest = '/' then dest = ''
-
- dlen = length(dest)
-
- bytes = 0
- files = 0
- dircount = 1
-
- say 'Equalize is doing it''s job on 'dest
-
- call dolist(dest)
-
- say
- say 'Deleted:' files 'files in a total 'dircount' directories.'
- say 'This equalization cleared:' bytes 'Bytes.'
- exit 0
-
-
- /* The real thing */
-
- dolist: procedure expose files root dest dlen dircount bytes dstat
- parse arg x
- contents = showdir(x);
- do i = 1 to words(contents)
- temp = x || word(contents,i)
- type = statef(temp)
- if word(type,1) = 'FILE' then
- do
- snam = root || right(temp,(length(temp) - dlen))
- if ~ exists(snam) then
- do
- files = files + 1
- bytes = bytes + word(type,2)
- if dstat = 1 then
- do
- 'delete 'temp
- say 'Deleted: 'temp
- end
- else say 'Would have deleted: 'temp
- end
- end
- if word(type,1) ='DIR' then do
- subdir = root || right(temp,(length(temp) - dlen))
- if ~ exists(subdir) then
- do
- say 'Subdirectory 'subdir' not found...'
- if dstat = 1 then
- do
- 'delete 'temp' all'
- say 'Removed: 'temp
- end
- else say 'Would have removed: 'temp
- end
- call dolist(temp || '/')
- dircount = dircount + 1
- end
- end
- return
-