ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Copy STMF to another directory from IFS

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Copy STMF to another directory from IFS

    Hi guys,
    How can I copy more streamfiles from a folder from IFS to another folder in the same IFS, on the same machine? I try with WRKLNK (I have a lot of files in the current folder, option 3 copy? but I don't know where is copied the object) & with the Navigator from Windows.
    I have also installed System i Navigator, the windows client for accessing the iSeries,- if I selected all the records, copy-paste method doesn't work? I saw I don't have the regular menu, I can't make paste in the new folder, if I use the Navigator window.

    Can you tell me a professional solution to realize the copy to the new folder please? Thanks

  • #2
    I do this;
    Code:
    Command = 'COPY OBJ('+ Quote + '/xxx/InBound/Invoice/' +       
              %Trim(In_FileName) + Quote + ') ' +                  
              'TODIR(' + Quote + '/xxx/InBound/Invoice/Archive' +  
               Quote + ') REPLACE(*YES)';                          
    QCmdExc(Command: %Len(%TrimR(Command)));


    This does one file but you can do a list of a directory to get a qtemp file;
    Code:
    Thislist = '/sftp/inbound/list' + NowTime +                   
               '.txt';                                            
                                                                  
    // Build list                                                 
    Command = 'StrQsh Cmd(' + Quote +                             
              'touch -C 1252 ' + %Trim(ThisList) + ' ; ' +        
              'ls -F1 ' + %Trim(ThisDirectory) + ' > ' +          
              %Trim(ThisList) + Quote + ')';                      
    QCmdExc(Command: %Len(%TrimR(Command)));                      
                                                                  
    // Convert IFS file into DB file                              
    Command = 'CPYFRMIMPF FROMSTMF(' + Quote + %Trim(ThisList) +  
              Quote + ') TOFILE(QTEMP/TEMPLIST) ' +               
              'MBROPT(*REPLACE) RCDDLM(*LF) RMVBLANK(*NONE) ';    
    QCmdExc(Command: %Len(%TrimR(Command)));                      
    // Delete ThisList temp file                    
    Command = 'RMVLNK OBJLNK('+ Quote +             
       %Trim(Thislist) + Quote + ') ';              
    QCmdExc(Command: %Len(%TrimR(Command)));
    Then you just do a cursor of the templist and process the files you want.

    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

    Comment


    • #3
      Did you prompt Option 3?
      By default, the directory it copies it to is ".", which is the current directory so unless you enter a new filename, nothing will happen.

      Comment


      • #4
        ...which is the current directory so unless you enter a new filename, nothing will happen.
        Well, "current directory" doesn't exactly mean "current directory". That is, it means "current working directory". It might be set by the user profile's HOMEDIR() parameter, or by the CHGCURDIR command in a job, or by other means depending on run-time environment.

        On a system command line such as on the WRKLNK panel, DSPCURDIR can show the current working directory of a job. If the current working directory is the directory that the file is already in and no new name is entered, then essentially nothing will happen. But if they're different directories and no name (nor path) is entered, either the file will be copied to the current working directory or there'll be an error signaled.
        Tom

        There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

        Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

        Comment


        • #5
          I always thought "current directory" meant the directory you were currently in (like it would in QSH), and everytime I've actually tried/tested it, I've always done it from my home directory so it always confirmed my thinking lol. Thanks for the clarification Tom.

          Comment


          • #6
            john.sev99 It can get confusing, first because of the somewhat unfortunate naming, but also because it's probably often the "current directory" (i.e., the one you're currently "in").
            Tom

            There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

            Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

            Comment


            • #7
              I don't understand what is confusing...? As far as I can tell, "current directory", "current working directory" and "directory you are 'in'" all mean the same thing -- they do NOT mean your home directory (unless your current directory happens to be your home directory at the moment, which is the default when you first sign on).

              Can someone explain a situation where they don't mean the same thing?

              Comment


              • #8
                Originally posted by Scott Klement View Post
                Can someone explain a situation where they don't mean the same thing?
                Let's assume that my home directory is /home/tom, and it has two STMFs in it, named s1.txt and s2.txt, plus a subdirectory named subdir. In subdir, I have a STMF named s3.txt.

                If my home directory is my "current working directory", that's where a plain WRKLNK will go. I can then use option 5=Display to look into subdirectory "subdir" (or ./subdir). At that time, it can be thought that ./subdir is the "current directory" although /home/tom is still the "current working directory". It's possible to be "in" subdirectory ./subdir though it isn't the "current working directory" by twisting semantics.

                Also, at that time, entering option 3=Copy against s3.txt and pressing {Enter} will copy it from the "current directory" (./subdir) to the "current working directory" (/home/tom).

                It's just a matter of mixing up terminology, using it in a way that can have 'correct' meaning while simultaneously conflicting with strict technical definitions. The term "current directory" in that sense is simply "the one you happen to be looking in".

                For something like this, you won't run into confusions because the idea of "current directory" and "current working directory" should always have the same meaning to you. But until someone else fully grasps the importance of the single concept, the first term can mean something different. Potential confusions result.
                Tom

                There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

                Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

                Comment


                • #9
                  Thanks, Tom, that makes sense.

                  Comment

                  Working...
                  X