Using SAV to save specific objects from directory tree

1145 pts.
Tags:
AS/400
Backup and Recovery
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • JDWWms
    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 pointsBadges:
    report
  • hafwhit
    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 pointsBadges:
    report
  • JDWWms
    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 pointsBadges:
    report
  • Alasdair727
    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 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following