Anthony,

You could expand on this routine to check for file sizes as well.

Here is a little utility we use now and then to remove a lot of temp files
from our system for records older than 10 days (based on create date).
Probably should change this to last modified!

The zoutput.temp file is a type 1 file too that is used to create a little
batch file in it. 

Use DIR /?  to see all the options for DIR that I think last modified is one
of the column options..


Anyway, here is the code:

----------------------------------

* purges temp files from type 1 files using date and time
*
* TDB 10-17-03 08:14a Updated for running on win 2003 server
*
EQU AM TO CHAR(254)
EQU MAX TO 999999
*
OPEN "ZOUTPUT.TEMP" TO F.ZOUTPUT.TEMP ELSE STOP 201, "ZOUTPUT.TEMP"
*
BAT.PATH = FILEINFO(F.ZOUTPUT.TEMP, 2)
CONVERT "/" TO "\" IN BAT.PATH
CRT BAT.PATH
*
LAST.PURGE.DATE = DATE() - 10
CRT OCONV(LAST.PURGE.DATE, "D2-")
*
PORT.NO = SYSTEM(18)
*
FILE.LIST = "&HOLD& &COMO& &ED& &PH& &SAVEDLISTS& &TEMP&"
*
N.FILES = DCOUNT(FILE.LIST, " ")
FOR I.FILES = 1 TO N.FILES
  FILE.NAME = FIELD(FILE.LIST, " ", I.FILES)
  CRT
  CRT FILE.NAME
  CRT
  OPEN FILE.NAME TO F.SOURCE THEN
*
    PATH = FILEINFO(F.SOURCE, 2)
    PATH.PART1 = FIELD(PATH, "/", 1)
    PATH.PART2 = FIELD(PATH, "/", 2)

    BATCH.FILE = "cd ":PATH.PART1
    BATCH.FILE<-1> = 'dir "':PATH.PART2:'"'
    BATCH.ID = "BATCH":PORT.NO:".BAT"
    WRITE BATCH.FILE ON F.ZOUTPUT.TEMP, BATCH.ID
    TCL = "DOS /C ":BAT.PATH:"\":BATCH.ID
    EXECUTE TCL CAPTURING OUTPUT
    SELECT OUTPUT TO S.OUTPUT
    EOF = 0
    LOOP
      READNEXT LINE FROM S.OUTPUT ELSE EOF = 1
    UNTIL EOF DO
      IF (LINE[1, 8] MATCH "2N/2N/2N") OR (LINE[1, 10] MATCH "2N/2N/4N")
THEN
*
* filename is at position 40
*
        FILE.INFO = LINE[1, 39]
*
* skip <DIR> type entries
*
        IF INDEX(FILE.INFO, "<", 1) ELSE
          DATE = ICONV(TRIM(FIELD(FILE.INFO, " ", 1)[1, 10]), "D")
          IF DATE = "" ELSE
            IF DATE > 0 THEN
              IF DATE <= LAST.PURGE.DATE THEN
                ID = LINE[40, MAX]
                ID = EREPLACE(ID, "%B", "\")
                ID = EREPLACE(ID, "%C", ":")
*
* this routine gets rid of ID's with control chars in them
*
*
                IF INDEX(ID, "^", 1) THEN
                  FOR I.ALPHA = 1 TO 26
                    SEARCH.STRING = "^":CHAR(I.ALPHA + 64)
                    REPLACE.STRING = CHAR(I.ALPHA)
                    ID = EREPLACE(ID, SEARCH.STRING, REPLACE.STRING)
                  NEXT I.ALPHA
                END
*
                CRT LINE
                DELETE F.SOURCE, ID
              END
            END
          END
        END
      END
    REPEAT
  END
NEXT I.FILES
STOP
*

----------------------------------


-----Original Message-----
From: Anthony Dzikiewicz [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 05, 2004 1:08 PM
To: [EMAIL PROTECTED]
Subject: [U2] Universe Sequential File Attributes


How would one go about analyzing a type 1 file records in UV for ;

1. the creation date was within a range,
2. or file size was at least nnn large.

Im working on automating some 'backups' and now Im up against this wall.  I
remember a long time ago there was a way to get this info in PI/OPEN.  In
Unix I could always do something in the shell, but the platform Im working
on is Windows where this type of thing isn't available.

Anthony Dzikiewicz
-------
u2-users mailing list
[EMAIL PROTECTED]
http://www.u2ug.org/listinfo/u2-users

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
-------
u2-users mailing list
[EMAIL PROTECTED]
http://www.u2ug.org/listinfo/u2-users

Reply via email to