home *** CD-ROM | disk | FTP | other *** search
- /* arcall.rexx - an ARexx program that will ARC all files within a
- directory, including subdirectories. It will rename all
- files to the form 'File1', 'File2', etc. and will
- generate a standard Amigados script file that will
- be included in the .ARC file. This script file, when
- executed, recreates the original file structure, creating
- any necessary subdirectories and renaming all files back
- to their original names.
- Arcall will take an optional argument consisting of the
- name of the directory you wish to operate on. Otherwise
- it will ARC the contents of the current directory.
-
- WARNING: This program does not handle filenames containing spaces.
-
- By Larry Phillips. Compuserve: 76703,4322
- Use this code in whatever way you like.
- */
-
- parse arg root
-
- if words(root) = 0 then root = pragma('d')
- if right(root,1) ~= ':' then root = root || '/'
- if root = ':' then root = ''
-
- filecount = 1
-
- 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."')
- 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."')
- end
-
- call writeln(execfile,'')
-
- call renamefiles(root)
-
- say
- call close(execfile)
- address command 'arc a' root || 'arcfile' root || '*'
- exit 0
-
- renamefiles: procedure expose filecount root
- parse arg x
- contents = showdir(x);
- do i = 1 to words(contents)
- temp = x || word(contents,i)
- type = statef(temp)
- select
- when word(type,1) = 'FILE' then do
- address command rename temp root || 'File' || filecount
- call writeln(execfile,'rename File' || filecount x || word(contents,i))
- call writech(stdout,'.')
- filecount = filecount + 1
- end
- when word(type,1) = 'DIR' then do
- call writeln(execfile,'')
- call writeln(execfile,'if NOT EXISTS' temp)
- call writeln(execfile,' makedir' temp)
- call writeln(execfile,'endif')
- call writeln(execfile,'')
- call renamefiles(temp || '/')
- 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
-