line erase

Help
2014-05-22
2014-05-26
  • Brant McClelland

    I'm trying to erase unwanted files from a directory.
    My software changes some file names to have a comma
    and a number appended to the extension. I can't get
    Rexx to understand the name: xxxxxxxx.scr,1

    If there are two files with the same name,
    it only
    finds the one without the , in the extension.
    In the following example there are two files in
    the directory:

    xxxxxxxx.jrl
    xxxxxxxx.jrl,1

    do until lines(infile) = 0 / start the directory listing loop /
    l = (linein(infile)) / define the line variable /
    parse var l . / parse the line /
    if right(l,4) = '.jrl' then erase l / remove .jrl files /

    if right(l,6) = '.jrl,1' then erase l / remove ,1 files /
    if right(l,2) = ',2' then erase l / remove ,2 files /
    if right(l,2) = ',3' then erase l / remove ,3 files /

    if right(l,1) = '%' then erase l / remove % files /
    if right(l,7) = 'SAV.lnk' then erase l / remove the .SAV files /
    if right(l,4) = '.SAV' then erase l / remove the .SAV files /
    if l = 'AUTO.brd' then erase l / remove the AUTO.brd file /
    if l = 'signoise.run' then 'rmdir /s /q' l / remove the signoise.run dir /
    end / end the directory listing loop /

    After finding and erasing xxxxxxxx.jrl it gets to xxxxxxxx.jrl,1 and reports
    Could not find .......xxxxxxxx.jrl

    It doesn't understand that the file name continues past the comma.
    Any help would be appreciated.

     
    • Rick McGuire

      Rick McGuire - 2014-05-22

      ERROR! The markdown supplied could not be parsed correctly. Did you forget to surround a code snippet with "~~~~"?

      Just a guess, but I suspect the command shell is interpreting the comma as
      an argument delimiter.  I suspect enclosing the name in quotes on the
      command can fix this.  That is, change
      
         erase l
      
      to
      
         erase '"'l'"'
      
      Another option would be to try using SysFileDelete, which will bypass the
      command shell parsing entirely (and be faster).
      
      Rick
      
      
      On Thu, May 22, 2014 at 10:33 AM, Brant McClelland <telluoff@users.sf.net>wrote:
      
      > I'm trying to erase unwanted files from a directory.
      > My software changes some file names to have a comma
      > and a number appended to the extension. I can't get
      > Rexx to understand the name: xxxxxxxx.scr,1
      >
      > If there are two files with the same name,
      >  it only
      > finds the one without the , in the extension.
      > In the following example there are two files in
      > the  directory:
      >
      > xxxxxxxx.jrl
      > xxxxxxxx.jrl,1
      >
      > do until lines(infile) = 0                   /* start the directory
      > listing loop */
      >    l = (linein(infile))                              /* define the line
      > variable */
      >    parse var l .                                               /* parse
      > the line */
      >    if right(l,4) = '.jrl' then erase l                      /* remove .jrl
      > files */
      >
      >    if right(l,6) = '.jrl,1' then erase l                      /* remove ,1
      > files */
      >    if right(l,2) = ',2' then erase l                      /* remove ,2
      > files */
      >    if right(l,2) = ',3' then erase l                      /* remove ,3
      > files */
      >
      >
      >    if right(l,1) = '%' then erase l                            /* remove %
      > files */
      >    if right(l,7) = 'SAV.lnk' then erase l               /* remove the .SAV
      > files */
      >    if right(l,4) = '.SAV' then erase l                  /* remove the .SAV
      > files */
      >    if l = 'AUTO.brd' then erase l                    /* remove the
      > AUTO.brd file */
      >    if l = 'signoise.run' then 'rmdir /s /q' l     /* remove the
      > signoise.run dir */
      > end                                            /* end the directory
      > listing loop */
      >
      > After finding and erasing xxxxxxxx.jrl it gets to xxxxxxxx.jrl,1 and
      > reports
      > Could not find .......xxxxxxxx.jrl
      >
      > It doesn't understand that the file name continues past the comma.
      > Any help would be appreciated.
      >
      >
      >
      > ---
      >
      > [line erase](
      > https://sourceforge.net/p/oorexx/discussion/408478/thread/2c346a96/?limit=50#1a86
      > )
      >
      >
      > ---
      >
      > Sent from sourceforge.net because you indicated interest in <
      > https://sourceforge.net/p/oorexx/discussion/408478/>
      >
      > To unsubscribe from further messages, please visit <
      > https://sourceforge.net/auth/subscriptions/>
      >
      
       
  • Brant McClelland

    I tried your suggestion with these results:

    input directory has two files named:
    pad_designer.jrl,1
    pad_designer.jrl,2
    

    sysfiledelete(pad_designer.jrl,1)
    reports 'sysfiledelete' is not recognized as an internal
    or external command, operable program or batch file

    if right(l,2) = '"',1'"' then erase l
    reports THEN expected found ","

    if right(l,2) = ',1' then erase l
    reports THEN expected found ","

    if right(l,2) = ",1" then erase l
    reports Could not find pad_designer.jrl

    if right(l,2) = '"','"'1 then erase l
    reports THEN expected found ","

    if right(l,2) = ","1 then erase l
    reports Could not find pad_designer.jrl

    If l = pad_designer.jrl,1 then erase pad_designer.jrl,1
    reports THEN expected found ","

    No matter how I format it the parsing stops at the comma.
    Does anyone know how to do this?

     
  • Rick McGuire

    Rick McGuire - 2014-05-26

    I have no idea what you are doing here...the change with the quotes I suggested was the the erase command, not to the IF conditions. Sysfiledelete is a standard part of rexxutil, it should be there. What version of ooRexx are you using?

    Rick

     
  • Brant McClelland

    regina 3.2

    Sysfiledelete does not support wild cards and some of the files I want to delete (erase) have different names and extensions followed by a comma and number, thus the problem.
    Brant

     
  • Rick McGuire

    Rick McGuire - 2014-05-26

    Why are you asking regina questions in the ooRexx forum? That is a different interpreter that has no relation to this one.

     
  • Moritz Hoffmann

    Moritz Hoffmann - 2014-05-26

    Hi Brant,
    I think you should switch to ooRexx if there's nothing holding you to Regina. ooRexx is actively maintained :-)

    As for your question, you should try to examine the evaluated results using the appropriate trace instruction, for example i. Then you should see what's passed to the OS.

    Moritz

     
  • Brant McClelland

    I appreciate your input and will investigate oorex. I didn't realize they were not the same. Will I have the same problem in oorexx? And if not, how do you get around it?
    Brant

     
    • Rick McGuire

      Rick McGuire - 2014-05-26

      ERROR! The markdown supplied could not be parsed correctly. Did you forget to surround a code snippet with "~~~~"?

      Here's a short program that shows how to erase this file.
      
      -- trace all of the issued commands
      trace commands
      
      file = "some.bogus.file,1"
      
      -- create the file.  Note the quotes surrounding the file name variable
      'echo Hello World > "'file'"'
      -- show the file is there
      'dir some*'
      -- this will fail because of the comma
      'erase' file
      -- the file is still there
      'dir some*'
      -- this will succeed because the name is quoted
      'erase "'file'"'
      -- the file is now gone
      'dir some*'
      -- now once more with SysFileDelete
      'echo Hello World > "'file'"'
      call sysfiledelete file
      'dir some*'
      
      
      
      On Mon, May 26, 2014 at 5:22 PM, Brant McClelland <telluoff@users.sf.net>wrote:
      
      > I appreciate your input and will investigate oorex. I didn't realize they
      > were not the same. Will I have the same problem in oorexx? And if not, how
      > do you get around it?
      > Brant
      >
      >
      > ---
      >
      > [line erase](
      > https://sourceforge.net/p/oorexx/discussion/408478/thread/2c346a96/?limit=25#99da
      > )
      >
      >
      > ---
      >
      > Sent from sourceforge.net because you indicated interest in <
      > https://sourceforge.net/p/oorexx/discussion/408478/>
      >
      > To unsubscribe from further messages, please visit <
      > https://sourceforge.net/auth/subscriptions/>
      >
      
       
    • Rick McGuire

      Rick McGuire - 2014-05-26

      ERROR! The markdown supplied could not be parsed correctly. Did you forget to surround a code snippet with "~~~~"?

      I've already answered that question twice.  Your problem is how you are
      coding the erase command.
      
      Rick
      
      
      On Mon, May 26, 2014 at 5:22 PM, Brant McClelland <telluoff@users.sf.net>wrote:
      
      > I appreciate your input and will investigate oorex. I didn't realize they
      > were not the same. Will I have the same problem in oorexx? And if not, how
      > do you get around it?
      > Brant
      >
      >
      > ---
      >
      > [line erase](
      > https://sourceforge.net/p/oorexx/discussion/408478/thread/2c346a96/?limit=25#99da
      > )
      >
      >
      > ---
      >
      > Sent from sourceforge.net because you indicated interest in <
      > https://sourceforge.net/p/oorexx/discussion/408478/>
      >
      > To unsubscribe from further messages, please visit <
      > https://sourceforge.net/auth/subscriptions/>
      >
      
       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks