home *** CD-ROM | disk | FTP | other *** search
- /* zooAll.rexx - an ARexx program that will ZOO all files within a
- directory, including subdirectories. It will
- generate a standard AmigaDOS script file, where
- necessary, that will be included in the .ZOO file. This
- script file, when executed, recreates the original file
- structure, creating any necessary subdirectories.
- The resultant .ZOO file is given the same NAME of its
- SOURCE directory.
-
- USAGE: rx zooall device:[directory] [device:[directory]] [d]
- arg1 arg2 arg3*
- where arg1 is the source,
- and its device the default destination
- arg2 is an optional destination
- arg3 if 'd', deletes the source directory
-
- *arg2 must be in place for arg3 to function
-
- zooAll is based on 'arcall.rexx' By Larry Phillips.
- zooAll By Dave Wilson, CIS
-
- Use this code in whatever way you like.
- */
-
- parse arg root dest action
-
- if words(root) = 0 then root = pragma('d')
- if right(root,1) ~= ':' then root = root || '/'
- if dest = ':' then dest = ''
-
- if right(root,1) = ':' then device = root
- else device = delstr(root,pos(':',root)+1)
- if words(dest) = 0 then dest = device
-
- directory = delstr(strip(root,'T','/'),1,3)
-
- if root ~= device then do
- begin = lastpos('/',strip(directory,'L',':'))
- dir = delstr(strip(directory,'L',':'),1,begin)
- source = root
- end
- else do
- dir = 'zoofile.zoo'
- source = root || '*'
- end
-
- contents = showdir(root)
- do i = 1 to words(contents)
- temp = root || word(contents,i)
- type = statef(temp)
- if word(type,1) = 'DIR' then leave
- if i = words(contents) then do
- address command 'zoo aP' dest || dir source
- if action = 'd' then do
- address command delete strip(root,'T','/') ALL
- end
- exit 0
- end
- end
-
-
- if ~exists(root || 'exec.me') then
- do
- dummy = open(execfile,root || 'Exec.me','write')
- call writeln(execfile,'echo "You may delete the file called EXEC.ME when the prompt comes back."')
- call writeln(execfile,'')
- call writeln(execfile,'if NOT EXISTS' directory)
- call writeln(execfile,' makedir' directory)
- call writeln(execfile,'endif')
- end
- else
- do
- dummy = open(execfile,root || 'Execute.me','write')
- call writeln(execfile,'echo "WARNING:"')
- call writeln(execfile,'echo "This archive contains a file called EXEC.ME"')
- call writeln(execfile,'echo "You will probably need to execute it after this script ends."')
- call writeln(execfile,'echo "You can delete EXECUTE.ME when the prompt comes back."')
- call writeln(execfile,'')
- call writeln(execfile,'if NOT EXISTS' directory)
- call writeln(execfile,' makedir' directory)
- call writeln(execfile,'endif')
- end
-
- call writeln(execfile,'')
-
- call renamefiles(root)
-
- say
- call close(execfile)
- address command 'zoo aP' dest || dir source
- if action = 'd' then do
- address command delete strip(root,'T','/') ALL
- end
- exit 0
-
-
- renamefiles: procedure expose root directory subDir
- parse arg x
- contents = showdir(x);
- do i = 1 to words(contents)
- temp = x || word(contents,i)
- temp2 = delstr(temp,1,3)
- type = statef(temp)
- select
- when word(type,1) = 'DIR' then do
- subDir = word(contents,i)
- call writeln(execfile,'')
- call writeln(execfile,'if NOT EXISTS' temp2)
- call writeln(execfile,' makedir' temp2)
- call writeln(execfile,'endif')
- call writeln(execfile,'')
- call renamefiles(temp || '/')
- end
- when word(type,1) = 'FILE' then do
- if subDir = 'SUBDIR' then subDir = strip(directory,'L',':')
- call writeln(execfile,'rename ' subDir || '_' || word(contents,i) temp2)
- address command rename temp root || subDir || '_' || word(contents,i)
- call writech(stdout,'.')
- end
- otherwise do
- if right(translate(temp),7) = 'EXEC.ME' then break
- if right(translate(temp),10) = 'EXECUTE.ME' then break
- else say 'Error: File' temp 'is neither DIR nor FILE.'
- end
- end
- end
- call writeln(execfile,'')
- return 0
-