;+ ; NAME: ; PKZIP_QL ; PURPOSE: ; Create a .ZIP archive of all quick-look files, including the ; yymmddQL.PS plot file, for a given date. Optionally the archived ; files can be deleted, and/or the progress of the routine can be ; displayed. ; CATEGORY: ; Utility. ; CALLING SEQUENCE: ; PKZIP_QL, YYMMDD, DELETE = delete, VERBOSE = verbose ; INPUTS: ; YYMMDD: A LONG integer expressing the date of the observations ; stored in the files to be archived. ; OPTIONAL INPUTS: ; None. ; KEYWORD PARAMETERS: ; /DELETE: If set, delete all individual files after the archive ; is created. ; /VERBOSE: If set, list all files stored in the archive, and the ; archive file name. ; OUTPUTS: ; None. ; OPTIONAL OUTPUTS: ; None. ; COMMON BLOCKS: ; None. ; SIDE EFFECTS: ; An archive file is created. If /DELETE is set, the archived ; files are deleted. ; RESTRICTIONS: ; YYMMDD must be a LONG integer, i.e., it cannot be a STRING. ; At least one file in the appropriate QL directory must exist ; that matches the YYMMDD pattern, and that does not have a .ZIP ; extension. ; PROCEDURE: ; Straightforward: SPAWN,'c:\utils\pkzip ...'. All files that ; match the pattern YYMMDD+'??.??' are archived. This includes ; files like YYMMDDCF.ql and YYMMDDql.ps, and excludes files like ; YYMMDDql.zip. ; EXAMPLE: ; ; SEE ALSO: ; ; MODIFICATION HISTORY: ; Written by: DP Steele, March 3, 1997. ;- PRO pkzip_ql,yymmdd,delete=delete,verbose=verbose ; Show header if called incorrectly. problem=(N_Params() NE 1) ; no YYMMDD supplied IF NOT problem THEN BEGIN s=Size(yymmdd) type=s(s(0)+1) problem=(s(0) NE 0) OR $ ; non-scalar argument (type EQ 0) OR $ ; UNDEFINED argument (type GT 5) ; STRING, STRUCTURE, or COMPLEX argument ENDIF IF problem THEN BEGIN Doc_Library,'pkzip_ql' Return ENDIF ELSE yymmdds=String(yymmdd,Format='(I6)') ; Define OS-specific parameters. @isitdos ; Ensure keyword values are correct. IF N_Elements(delete) GT 0 THEN delete=1 ELSE delete=0 IF N_Elements(verbose) GT 0 THEN verbose=1 ELSE verbose=0 ; Define file name pattern to match. pattern=qlroot+dd+yymmdds+'??.??' match=rFindFile(pattern,Count=nmatch) IF nmatch LT 1 THEN BEGIN Message,'No files found to archive',/Informational Return ENDIF IF verbose THEN BEGIN Print,'Files to archive:' FOR im=0,nmatch-1 DO Print,match(im) ENDIF ; Set up the elements of the SPAWNed command cmd='c:\utils\pkzip ' archive=qlroot+dd+yymmdds+'ql.zip ' ; Do the actual work! IF verbose THEN Print,cmd+archive+pattern Spawn,cmd+archive+pattern ; Check the results IF verbose THEN Print,'Pattern: '+qlroot+dd+yymmdds+'*.*' ; Locate all files with YYMMDD in their names. all=StrUpCase(rFindFile(qlroot+dd+yymmdds+'*.*',Count=nall)) ; Locate all such files with .ZIP extensions. wzip=Where(StrPos(all,'.ZIP') GT 0,nwzip) CASE nwzip OF 0: Print,'No .ZIP files found!' 1: Print,'File created: '+all(wzip) ELSE: BEGIN Print,'More than one .ZIP file!' Print,all(wzip) END ENDCASE ; Delete the archived files if requested and safe to do so. IF delete AND (nwzip EQ 1) THEN BEGIN IF verbose THEN Print,'Deleting archived files...' FOR im=0,nmatch-1 DO del,match(im) ENDIF Return END