1,145 pts.
 Using SAV to save specific objects from directory tree
I need to save objects from multiple directories with the directory names and have not had any luck getting this to work. I am attempting to save the information to a save file. I need only the data with an extension of *.tif. The directory structure is like this: /abc/xyz/123-456-7777/1.psg /abc/xyz/123-456-7777/1.tif /abc/xyz/123-456-8888/1.psg /abc/xyz/123-456-8888/1.tif /abc/xyz/123-456-8888/2.psg /abc/xyz/123-456-8888/2.tif /abc/xyz/123-456-9999/1.psg /abc/xyz/123-456-9999/1.tif I want to save all the *.tif objects but not the *.psg objects. There are some additional extensions as well but if I can get the SAV to exclude the *.psg I should be able to figure out how to do the others. I wish to end up with the data in the save file like this: /abc/xyz/123-456-7777/1.tif /abc/xyz/123-456-8888/1.tif /abc/xyz/123-456-8888/2.tif /abc/xyz/123-456-9999/1.tif

Software/Hardware used:
ASKED: December 11, 2006  6:37 PM
UPDATED: December 14, 2006  7:12 AM

Answer Wiki:
It's been a while since I dealt with this but messing around with entries on the directories on the IFS made me write so interesting little CL's. There are probably easier ways to do this but here's what worked for me. First you'll have to output the entries of all the directories you are concerned with to a file. I have looked through my notes and I can't remember exactly how I did it. Maybe someone else can help. Then I used a program to read the records in the file of entries. Each time I found an entry that matched my criteria I called a CL that expected the Directory name to be passed as a parm. So you go through the list of entries and if the extenson is TIF you call the CL and pass the directory name. Then you save the name of the directory you just passed in your program. Since the records in the file will be in the order of the directories you skip the following recrds in the directory entry file if it is the same as what you have already passed to the cl to save the directory. This is to avoid saving the directory multiple times when a directoriey has multiple tifs. In the CL you concatenate the directory name passed with '/*.tif'. So if the directory passed to the CL is '/abc/xyz/123-456-7777/' you combine that with '/*.tif' so that your save command looks like SAV OBJ('/abc/xyz/123-456-7777/*.tif') in the CL you'll have 3 variables. &indire for inbound directory to be saved. Make it large enough to hold the largest directory name you'll be dealling with. type *char &contif for the constant '/*.tif' to be added onto the inbound directory name. length 6 *char &savdir for the concaenated directory name 6 longer than &indire type *char Concatenate &indire with &contif into &savdir then excute command SAV OBJ(&savdir) to the save file you want. I can't remember if you can keep adding to a save file without monitoring for an error condition. Anyway this might be a little long and someone else may have a better answer but I hope this helps. On the other hand if you simply executed the sav OBJ with the *all it should get all the tifs without the need for programs as talked about above. Device . . . . . . . . . . . . . > 'save-file-path-name' + for more values Objects: Name . . . . . . . . . . . . . > '/abc/*.tif' Include or omit . . . . . . . *INCLUDE *INCLUDE, *OMIT + for more values Directory subtree . . . . . . . *ALL *ALL, *DIR, *NONE, *OBJ, *STG Save active . . . . . . . . . . *NO *NO, *YES, *SYNC Output . . . . . . . . . . . . . *NONE The directory subtree *all is suposed to mean Directory subtree (SUBTREE) - Help *ALL The entire subtree of each directory that matches the object name pattern is included. The subtree includes all subdirectories and the objects within those subdirectories. Hope this helps.
Last Wiki Answer Submitted:  December 12, 2006  2:42 am  by  IdratherBEFishing   0 pts.
All Answer Wiki Contributors:  IdratherBEFishing   0 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

If the directories and extension are always the same you should be able to hardcode a CL to do it this way.

SAV DEV(‘/QSYS.LIB/yourlib.LIB/yoursavf.FILE’) OBJ((‘/dir1/dir2/*.ext’)(‘/dir3/dir4/*.ext’))

You can have up to 300 obj entries in the list.
If you want to build it as a varible it might be easiest to build the entire command string and use

CALL PGM(*LIBL/QCMDEXC) PARM(&CMD 1000)

to run it.

 0 pts.

 

I had considered the creation of a file to retrieve the specific entries but wanted to see if someone had an easier solution. I have about 17000 subdirectories and if I save everything I end up with a save file of 650 MB. The file is on a remote system and I need to transfer it to the local system. I don’t use the SAV command that often and wanted to make sure I did not overlook something.

I appreciate the suggestions.

 1,145 pts.

 

With that many objects to move have you considered just FTPing the objects to the target location. Then you wouldn’t even need the save file.

Also if the target just needs to access the files you could setup a Symbolic link between the systems and not even move then but still have access from both system.

 0 pts.

 

If all these files are on the IFS, it might be easier to map it as a windows drive and use something like Winzip to save a copy & move them over. Point it at the top level directory give it a wildcard match like *.png and tick the box to include all subdirectories. It won’t be in native OS/400 format but it might be a lot easier than using SAV (although harder to automate). It depends on whether this is a one-off or something you have to do every day.

 0 pts.