/* basic speedbatch engine core. a thp/©!truS'96 speedhack. $VER: BatchCore.rx 1.2 (1.07.96) Copyright © Almathera 1996. All rights reserved. currently, using 'showdir' from rexxsupport.library can't cope with filenames with spaces in them. shrug. note the use of d2c(34,1) clauses around filenames, this is a neat way to get "s around string variables so the Photogenics command parsing will work correctly. */ addlib('rexxsupport.library',0,-30,0) options results address PHOTOGENICS.1 ASKDRAWER '"Directory to batch from:"' "ram:" /* get the source directory */ dir_in = result if dir_in == "" then do SHOWERROR '"No in-batch directory selected"' exit end ASKDRAWER '"Directory to batch to:"' "ram:" /* get a destination directory */ dir_out = result if dir_out == "" then do SHOWERROR "No out-batch directory selected" exit end OPENPROGRESS '"Batchprocessing files"' '""' /* open the progress */ SETPROGRESS "" 0 files_to_check = showdir(dir_in,'f') /* get list of files */ n_files = words(files_to_check) r = 1 do until r = n_files + 1 currentfile = word(files_to_check,r) /* loop thru the list */ SETPROGRESS currentfile ( (100 / n_files) * r) /* and update the progress */ LOADHIDE d2c(34,1)||trimpath(dir_in)||currentfile||d2c(34,1) image = result /* basically, each image is loaded as hidden for speed, and an error is put up if the file is unrecognised or corrupt. this could be logged to a file, for example, with redirection of 'say' statements or real file i/o. if the file's okay, it's processed. here we're just saving them back out as 80% quality JPEGs to the destination directory, using the same filenames with ".JPG" appended on the end. */ if rc = -1 then /* this could be an error message sent to a log file or printer */ SHOWERROR d2c(34,1) || "Unrecognised: " || trimpath(dir_in) || currentfile || d2c(34,1) else do /* here you can apply effects, add frames to an animation stream, crop and scale the image, or simply take the image dimensions, filename, filesize and build up a database. */ SAVE image "JPEG" d2c(34,1) || trimpath(dir_out) || currentfile || ".JPG" || d2c(34,1) 80 CLOSE image /* and close the image, now we're done with it. */ end r = r + 1 /* increment the counter to access the next image */ end CLOSEPROGRESS /* shuts the progress window off and quits the script */ exit /* ----------------------------------------------------------------------- */ /* procedure to correct devices and directory headers as rexx desn't seem to have a tackon() equivalent built-in... */ trimpath: procedure stub = arg(1) if substr(stub,length(stub),1) ~== ":" then return substr(stub,1,length(stub)) || "/" else do return stub end