ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Deleting Files from Folder

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

  • Deleting Files from Folder

    Hi,

    I have a requirement where we do load a folder in QDLS with the files that need to be transmitted i.e. FTP and after tranmission is done we need to delete the documents in the folder.

    Consider I have a folder TESTFLR i.e. /QDLS/TESTFLR

    How can I delete all the docs in that folder using the FTP script after transmission?

    I have tried giving DEL *.* but I believe it is not working.

    Could somebody please tell me how to achieve my requirement?

    Thanks a lot in advance.

    Regards,
    Rahul

  • #2
    Re: Deleting Files from Folder

    Remember, you must start your ftp with the "-i" option to suppress Prompting for multiple files. Then, enter MDEL file*.*

    If you want to be prompted for each deletion, then do NOT specify the -i option as mentioned.

    hth

    -Rick

    Comment


    • #3
      Re: Deleting Files from Folder

      I didnt know that....Thanks
      All my answers were extracted from the "Big Dummy's Guide to the As400"
      and I take no responsibility for any of them.

      www.code400.com

      Comment


      • #4
        Re: Deleting Files from Folder

        You're Welcome!

        Comment


        • #5
          Re: Deleting Files from Folder

          Hi,

          How can I start FTP with option "-i".

          I have docs in TESTING folder and I am trying to delete the docs in that folder.

          Please see below the code I am executing.



          Work with Documents in Folders

          Folder . . . TESTING
          Position to . . . . . . Starting characters

          Type options (and Document), press Enter.
          3=Copy 4=Delete
          7=Rename


          Opt Document Document Description Revised Type

          COMMON.CSV COMMON.CSV 04/05/07 PCFILE
          GC060911.TXT GC060911.TXT 04/05/07 PCFILE
          RT020706.TXT RT020706.TXT 04/05/07 PCFILE
          SALES002.TST SLS00002.TST 04/05/07 PCFILE



          Code:

          Connecting to host TEST1 at address 11.35.42.108 using port 21.
          220-QTCP at TEST1.
          220 Connection will close if idle more than 5 minutes.
          RAHUL
          331 Enter password.
          230 RAHUL logged on.
          OS/400 is the remote operating system. The TCP/IP version is "V5R2M0".
          250 Now using naming format "0".
          257 "QGPL" is current library.
          NA 1
          250 Now using naming format "1".
          Server NAMEFMT is 1.
          Client NAMEFMT is 1.
          LCD /QDLS/TESTING
          Local working directory is /QDLS/TESTING
          DEL *.*
          501 File identifier not valid in DELETE subcommand.
          MDEL *.*
          227 Entering Passive Mode (10,98,32,108,137,205).
          501 Unknown extension in database file name.


          Thanks in advance for your help.

          Comment


          • #6
            Re: Deleting Files from Folder

            This is how you start up your FTP Session:

            FTP -i xxx.xxx.xxx.xxx

            But, look at your code below:
            PHP Code:
            257 "QGPL" is current library.
            NA 1
            250 Now using naming format 
            "1".
            Server NAMEFMT is 1.
            Client NAMEFMT is 1.
              LCD 
            /QDLS/TESTING
            Local working directory is 
            /QDLS/TESTING
            DEL 
            *.*
            501 File identifier not valid in DELETE subcommand.
            MDEL *.* 
            You're doing :

            LCD /QDLS/TESTING

            then

            MDEL *.*

            if the files you're wanting to delete are on in the QDLS, then you need to do:

            CD /QDLS/TESTING

            to put the SERVER into the correct location for deleting the files, otherwise get out of FTP and delete the files locally if they exist on the CLIENT.

            Comment


            • #7
              Re: Deleting Files from Folder

              Hi,

              My Process build files in Local Client's Folder and my requirement is to delete the files present locally after FTP in FTP script if possible.

              However I can do that after doing an FTP but wanted to know if we can do it within FTP.

              Thanks for your help.

              Regards,
              Rahul

              Comment


              • #8
                Re: Deleting Files from Folder

                Then, try the following:

                FTP -i xxx.xxx.xxx.xxx

                ...
                NamFmt 1
                LCD /QDLS/<Folder>
                !Del *.*
                ...

                Comment


                • #9
                  Re: Deleting Files from Folder

                  do a search on QUOTE , FTP, AS400

                  Many of you use FTP to transfer files between systems, and FTP is an excellent tool for that purpose. Did you also know that by using FTP, you can enter commands on remote systems? You can do this with the quote command. The quote command lets you send arbitrary commands to the FTP server. By using server sub-commands in conjunction with the quote command, you can execute most AS/400 commands from within your FTP session. Using this approach, you can create files, restore objects, etc. as part of your FTP job stream. The AS/400 sub-command that allows you to do this is rcmd, which allows you to execute remote commands through your FTP server.

                  Example: quote rcmd CLRPFM FILE(MYLIB/MYFILE) -- Will clear the specified file on the remote system

                  If you are in an FTP session and want to enter a command on the LOCAL system, you can use the ! command. This works a little differently on the AS/400 and in Windows.

                  If you enter ! from the a Windows DOS prompt FTP session, you temporarily exit to the DOS prompt until you decide to resume your FTP session. If you enter ! from an AS/400 FTP session, the AS/400 expects you to follow it with an AS/400 command.

                  Example: ! sndmsg msg(Hello) tousr(tim)

                  Although not related to the topic at hand, here is another server sub-command I find very useful:

                  By default, your FTP session will time out after five minutes of inactivity. Using the time command you can increase that amount of time to whatever you choose.

                  Example: quote time 10000 -- Sets the FTP inactivity timeout to 10,000 seconds


                  All my answers were extracted from the "Big Dummy's Guide to the As400"
                  and I take no responsibility for any of them.

                  www.code400.com

                  Comment


                  • #10
                    Re: Deleting Files from Folder

                    Hi,

                    Jamie thanks for the info.

                    Also we can execute the SYSCMD command in Local system which will function similar to the QUOTE command.

                    SYSCMD ? CLRPFM

                    If you give ? and give the command it will behave as a prompt for the CLRPFM command and it will allow user to enter the values.

                    We can also give direct command as Jamie quoted such as

                    SYSCMD CLRPFM FILE(MYLIB/MYFILE)

                    Regards,
                    Rahul

                    Comment


                    • #11
                      Re: Deleting Files from Folder

                      I don't believe that will give you any interactive prompting at all. It is meant to give you the ability to run a command on the remote / local system by entering the whole command.

                      The "?" is usually set aside for displaying HELP in FTP

                      -Rick

                      Comment

                      Working...
                      X