Delete substring

I have two var name *var1* (exp nicolas van brussel)  and one var nachna  var2 (van brussel) how can i extract the vorna from the first string (delete the subtring var2 from var1 ).
Thanks in advance

Hi,
you can do this:
REPLACE var2 with ' ' into var1.
CONDENSE var1 NO-GAPS.
regards.

Similar Messages

  • Substring delete

    hi,
    may i know how to delete a substring in a string and the remaining string can move to the left.
    for example :
    401011DELEC345,99REF
    i need to delete "DELE" which is wa_tab+6(4) to become as below :
    401011C345,99REF
    thanks

    You can use REPLACE to replace the desired part of string by space and then use CONDENSE command to remove the spaces.
    ashish

  • Deleting leading substring from a string

    Hey guys,
    how can i delete a string from a leading substring?
    e.g.: "00022521" should become "22521".
    thx
    Markus

    I actually had written a little static class to handle just this.  Here is the static class.
    public class LeadingZeroRemover {
         public static String removeLeadingZeros(String str) {
              if (str == null) {
                   return null;
              char[] chars = str.toCharArray();
              int index = 0;
              for (; index < str.length(); index++) {
                   if (chars[index] != '0') {
                        break;
              return (index == 0) ? str : str.substring(index);
    Then you can simply use it like this.
    <b>LeadingZeroRemover.removeLeadingZeros</b> (soldToNumber.getValue().toString())
    Regards,
    Rich Heilman

  • How to delete file from client machine

    Hi all,
    we are using the DataBase: oracle:10g,
    and forms/reports 10g(developer suite 10g-10.1.2.2).
    can anybody help me how to delete the file from client machine in specified location using webutil or any
    (i tried with webutil_host & client_host but it is working for application server only)
    thank you.

    hi
    check this not tested.
    PROCEDURE OPEN_FILE (V_ID_DOC IN VARCHAR2)
    IS
    -- Open a stored document --
    LC$Cmd Varchar2(1280) ;
    LC$Nom Varchar2(1000) ;
    LC$Fic Varchar2(1280);
    LC$Path Varchar2(1280);
    LC$Sep Varchar2(1) ;
    LN$But Pls_Integer ;
    LB$Ok Boolean ;
    -- Current Process ID --
    ret WEBUTIL_HOST.PROCESS_ID ;
    V_FICHERO VARCHAR2(500);
    COMILLA VARCHAR2(4) := '''';
    BOTON NUMBER;
    MODO VARCHAR2(50);
    URL VARCHAR2(500);
    Begin
    V_FICHERO := V_ID_DOC;
    LC$Sep := '\';--WEBUTIL_FILE.Get_File_Separator ; -- 10g
    LC$Nom := V_FICHERO;--Substr( V_FICHERO, instr( V_FICHERO, LC$Sep, -1 ) + 1, 100 ) ;
    --LC$Path := CLIENT_WIN_API_ENVIRONMENT.Get_Temp_Directory ;
    LC$Path := 'C:';
    LC$Fic := LC$Path || LC$Sep || LC$Nom ;
    If Not webutil_file_transfer.DB_To_Client
    LC$Fic,
    'TABLE_NAME',
    'ITEM_NAME',
    'WHERE'
    ) Then
    Raise Form_trigger_Failure ;
    End if ;
    LC$Cmd := 'cmd /c start "" /MAX /WAIT "' || LC$Fic || '"' ;
    Ret := WEBUTIL_HOST.blocking( LC$Cmd ) ;
    LN$But := WEBUTIL_HOST.Get_return_Code( Ret ) ;
    If LN$But 0 Then
    Set_Alert_Property( 'ALER_STOP_1', TITLE, 'Host() command' ) ;
    Set_Alert_Property( 'ALER_STOP_1', ALERT_MESSAGE_TEXT, 'Host() command error : ' || To_Char( LN$But ) ) ;
    LN$But := Show_Alert( 'ALER_STOP_1' ) ;
    LB$Ok := WEBUTIL_FILE.DELETE_FILE( LC$Fic ) ;
    Raise Form_Trigger_Failure ;
    End if ;
    If Not webutil_file_transfer.Client_To_DB
    LC$Fic,
    'TABLE_NAME',
    'ITEM_NAME',
    'WHERE'
    ) Then
    NULL;
    Else
    Commit ;
    End if ;
    LB$Ok := WEBUTIL_FILE.DELETE_FILE( LC$Fic ) ;
    Exception
    When Form_Trigger_Failure Then
    Raise ;
    End ;sarah

  • How to delete file from application server(Unix)

    Hi All,
    Using the below code downloading a file from application server(Unix) to client machine. I want to delete the file from application server once it is downloaded to client
    We work on Forms 11.1.1.4.0 and Oracle DB 10g. Client machine are Windows 7.
    BEGIN
      IF webutil_file_transfer.AS_to_Client
      (clientFile => Name_In('global.g_file_name')
      ,serverFile => ls_AppServer_Loc)THEN
      message('Data exported Successfully');
      ELSE
       message('File download from Application Server failed');
      END IF;
    EXCEPTION
      WHEN OTHERS THEN
      message('File download failed: '||SUBSTR(sqlerrm,1,200));
      END;
    I have search for solution on OTN. Few suggested to use HOST.
    Can any one help me how to use Host() built_in to delete the file.
    Thanks,
    Maddy

    Can any one help me how to use Host() built_in to delete the file.
    Host('/bin/rm <complete file path>');

  • How do I delete cascade with a PL/SQL procedure?

    This script will create a PL/SQL procedure that deletes cascade. This is a post to contribute to the Oracle community. Take the code as is and test it before you use it in production. Make sure this is what you want.
    Procedure Delete Cascade (prc_delete_cascade)
    Description
    =============
    The principle is very simple. The procedure uses a table called TO_BE_DELETED to keep a list of records to be deleted. This
    table keeps the table name and the rowid of those records that need to be deleted. The procedure also uses a function called
    DELETE_BOTT_ROW which takes one record of the table and tries to delete it. If the deletion fails with a foreign key constraint
    violation, the function parses the SQL error message (SQLERRM) to get the name of the constraint. With the name of the constraint,
    the function finds the name of the child table, all the child records that have references to the parent table primary or unique key,
    and the parent key primary or unique key column name. Once the child records of the failed delete are identified, the function takes their table name and rowids
    and records them into the TO_BE_DELETED table by inserting records of their table name and their rowids. Al the records inserted also contain the level (which
    is 1 for the original records, 2 for child records, 3 for granchild records, etc.) and the sequence number of the order in wich they
    are recorded. This way, when the function picks up a record to be deleted, it takes the one with the highest level and the highest
    inserted sequence, or the "bottom" record. Once all the child records of the failed delete are appended to the TO_BE_DELETED table, it calls itself
    recursevely, and the function takes the record at the "bottom" of the table and tries to delete it. If it succeeds, it calls
    itself recursevely to delete the next record. If it fails, it goes and finds the child records as described before and once they are
    inserted into the TO_BE_DELETED table, it calls itself again recursevely to try to delete again the "bottom" record. All records
    that are successfully deleted are flagged as deleted usig the flag_del column so they are not pickt up again. Once all the (parent,
    child, grandchild, etc.) records are deleted, the procedure ends without commiting, giving the option to the user to commit or
    rollback deletions. The table TO_BE_DELETED is, at the end of the procedure, a list of all the records that were deleted, including their table names
    and the order in with they were deleted. The user then can review its content and decide to commit or rollback.
    Restrictions
    ============
    1. Single tables only. The procedure only takes one table name and a WHERE clause to identified the records to be deleted.
    2. Single columns only. Ther procedure only works with single-column primary, unique and foreign key constraints.
    3. Single schema only.
    4. Unpredictable results with circular references.
    drop table to_be_deleted purge;
    create table to_be_deleted
    (tname varchar2(30)       -- table name
    ,rid rowid                -- rowid
    ,lvl number               -- level: 1=parent, 2=child, 3=grandchild, etc.
    ,seq_ins number           -- sequence order of record inserted
    ,flg_del char             -- flag deleted: Y=record deleted
    ,seq_del number           -- global order of record deletion
    set serveroutput on size 1000000
    create or replace procedure prc_delete_cascade
    (p_tname varchar2  -- table name
    ,p_where varchar2  -- where clause identifying records to be cascade deleted
    is
      dummy         char;
      v_sqlcode     number;
      v_sqlerrm     varchar2(32767);
      v_param_val   integer := 0;
      v_sql         varchar2(4000);
      v_ret_cde     number;
      e_bad_params  exception;
      v_iter        number;
      v_plvl        number;
      v_seq_del     number;
      v_max_iter    number := 1000000000;
      function delete_bott_row
      return number
      is
        v_sql        varchar2(4000);
        v_ptname     varchar2(30);  -- parent table name
        v_ppkname    varchar2(30);  -- parent primary key constraint name
        v_ppkcname   varchar2(30);  -- parnet primary key column name
        v_prowid      rowid;
        v_crowid      rowid;
        v_ctname     varchar2(30);  -- child table name
        v_cfkname    varchar2(30);  -- child foreign key constraint name
        v_cfkcname   varchar2(30);  -- child foreign key column name
        v_ins        number;
        v_seq_ins    number;
        v_sqlerrm    varchar2(4000);
        v_sqlcode    number;
        e_const_viol exception;
        pragma exception_init(e_const_viol, -2292);
        e_max_iter_reached exception;
      begin
        v_iter := v_iter + 1;
        if v_iter >= v_max_iter then
          raise e_max_iter_reached;
        end if;
        dbms_output.put_line('- Iter '||to_char(v_iter));
        dbms_output.put_line('----------');
        dbms_output.put_line('- Starting function delete_bott_row');
        v_sql := 'select tname, rid, lvl, seq_ins from (select * from to_be_deleted where flg_del = ''N'' order by lvl desc, seq_ins desc) where rownum=1';
        --  dbms_output.put_line('- SQL: '||v_sql);
        execute immediate v_sql into v_ptname, v_prowid, v_plvl, v_seq_ins;
        dbms_output.put_line('- Selected row: table name: '||v_ptname||', level: '||v_plvl||', seq: '||v_seq_ins);
        v_sql := 'delete from '||v_ptname||' where rowid='''||v_prowid||'''';
        dbms_output.put_line('- SQL: '||v_sql);
        execute immediate v_sql;
        dbms_output.put_line('- Row deleted !!!');
        v_ret_cde := 1;
        v_seq_del := v_seq_del + 1;
        dbms_output.put_line('- Mark the row deleted');
        v_sql := 'update to_be_deleted set flg_del = ''Y'', seq_del = '||to_char(v_seq_del)||' where tname='''||v_ptname||''' and rid='''||v_prowid||'''';
        -- dbms_output.put_line('- SQL: '||v_sql);
        execute immediate v_sql;
        -- dbms_output.put_line('- Updated table to_be_deleted, row marked deleted');
        -- dbms_output.put_line('- End of iter '||to_char(v_iter));
        dbms_output.put_line('----------');
        -- call function delete_bott_row recursively
        v_ret_cde := delete_bott_row;
        return 0;
      exception
        when no_data_found then
          dbms_output.put_line('- Table to_be_deleted is empty, delete cascade has completed successfully.');
          v_ret_cde := 0;
          return 0;
        when e_const_viol then
          v_sqlcode := SQLCODE;
          v_sqlerrm := SQLERRM;
          v_ret_cde := v_sqlcode;
          dbms_output.put_line('>Constraint Violation. Record has children');
          -- dbms_output.put_line('Error code: '||to_char(v_sqlcode));
          v_cfkname := substr(v_sqlerrm,instr(v_sqlerrm,'.')+1,instr(v_sqlerrm,')') - instr(v_sqlerrm,'.')-1);
          dbms_output.put_line('>Child FK name: '||v_cfkname);
          select table_name, column_name
            into v_ctname, v_cfkcname
            from user_cons_columns
           where constraint_name=v_cfkname;
          dbms_output.put_line('>Child table name: '||v_ctname||'. FK column name: '|| v_cfkcname);
          select constraint_name, column_name
            into v_ppkname, v_ppkcname
            from user_cons_columns
           where constraint_name = (select r_constraint_name
                                      from user_constraints
                                      where constraint_name=v_cfkname);
          dbms_output.put_line('>Parent PK/UK name: '||v_ppkname||'. Parent PK/UK column: '||v_ppkcname);
          v_sql := 'insert into to_be_deleted(tname, rid, lvl, seq_ins, flg_del) '||
                   'select '''||v_ctname||''', rowid, '||to_char(v_plvl+1)||', rownum, ''N'' '||
                   'from '||v_ctname||' '||
                   'where '||v_cfkcname||' =any (select '||v_ppkcname||' from '||v_ptname||' where rowid =any (select rid from to_be_deleted where tname = '''||v_ptname||'''))';
          -- dbms_output.put_line('- SQL: '||v_sql);
          execute immediate v_sql;
          select count(*)
            into v_ins
            from to_be_deleted
           where lvl = v_plvl+1
             and tname = v_ctname
             and flg_del = 'N';
          dbms_output.put_line('>Found '||to_char(v_ins)||' child records which were added to table to_be_deleted');  
          v_ret_cde := delete_bott_row;
          return  v_ret_cde;
        when e_max_iter_reached then
          dbms_output.put_line('Maximum iterations reached.  Terminating procedure.');
          raise;
        when others then
          raise;
      end delete_bott_row;
    begin
      dbms_output.put_line('Beginning');
      dbms_output.put_line('================================');
      -- validate p_table
      begin
        select 'Y'
          into dummy
          from user_tables
         where table_name=upper(p_tname);
      exception
        when no_data_found then
        v_param_val := 1;
        dbms_output.put_line('Table '||p_tname||' does not exist.');
        raise e_bad_params;
      end;
      dbms_output.put_line('- Parameter p_tname validated');
      -- validate p_where
      begin
        execute immediate 'select ''Y'' from '||p_tname||' where '||p_where INTO dummy;
      exception
        when no_data_found then  -- where clause returns no records
          dbms_output.put_line('Record(s) not found.  Check your where clause parameter');
          v_param_val := 2;
          raise e_bad_params;
        when too_many_rows then  -- found multiple records means it is ok
          null; 
        when others then  --  any other records means where clause has something wrong.
          dbms_output.put_line('Where clause is malformed');     
          v_param_val := 2;
          raise e_bad_params;
      end;   
      dbms_output.put_line('- Parameter p_where validated');
      if v_param_val > 0 then raise e_bad_params; end if;
      v_iter := 0;
      v_plvl := 1;
      v_seq_del := 0;
      v_sql := 'insert into to_be_deleted(tname, rid, lvl, seq_ins, flg_del) select '''||upper(p_tname)||''', rowid, '||to_char(v_plvl)||', rownum, ''N'' from '||p_tname||' where '||p_where;
      dbms_output.put_line('- Inserting initial record');
      dbms_output.put_line('- SQL: '||v_sql);
      execute immediate v_sql;
      dbms_output.put_line('- Record(s) inserted');
      dbms_output.put_line('- Calling function delete_bott_row to delete last row of table to_be_deleted');              
      dbms_output.put_line('-----------------------------------');              
      v_ret_cde :=  delete_bott_row;
      -- dbms_output.put_line('- Back from function delete_bott_row');              
      -- dbms_output.put_line('Return code: '||to_char(v_ret_cde));              
      dbms_output.put_line('- End of procedure');              
    exception
      when e_bad_params then
        dbms_output.put_line('Bad parameters, exiting.');
    end;
    show errors
    spool prc_delete_cascade.log
    --  Call to the procedure
    exec prc_delete_cascade('xent','xent_id between 1669 and 1670')
    select tname "Table Name", count(*) "Rows deleted"
      from to_be_deleted
    group by tname;
    spool off
    set lines 120
    select *
      from to_be_deleted
    order by seq_del;
    prompt  Now commit or rollaback deletions.
    -- commit;
    -- rollback;Edited by: Rodolfo4 on Mar 23, 2011 10:45 AM

    Interesting.
    I see a few areas where this could be useful. Elimiating specific test records from a Test DB for example.
    Some comments:
    <li>Since this is a recursive logic you must add a stop criteria. In this case I would add a max iteration variable. If that one is reached, raise an error message and let the procedure stop with that error.</li>
    <li>The when others exception at the end should be removed completely</li>
    <li>The when others exception in the middle should be replaced by a specific exception that handles the -2292 error</li>
    <li>A list of tables where no record should be deleted could be usefull. If the logic would encounter such a table, it should also stop. This would be to prevent that data from some system critical tables could be deleted per accident.</li>
    <li>The reference from the FK constraint to the PK constraint should include the table name and if possible the owner (as long as you use user_* views the owner is always the same. But we could extend this to the ALL_* views). I never met a system where different tables have the identical FK constraint names, however just make this fool proof.</li>

  • How to add the delete statement in this procedure.

    I got a string from user e.g. ‘1,2,3’ and userid =14 from user;
    I wrote a procedure that will insert the record as follows;
    Userid newsletterid
    14     1
    14 2
    14 3
    The procedure is
    CREATE OR REPLACE PROCEDURE usersubscription_procd (vuserid in number, vnewsletterid IN VARCHAR2)
    AS
    I NUMBER;
    J NUMBER;
    VAL VARCHAR2(100);
    BEGIN
         I := 1;
         J := 1;
         WHILE INSTR(vnewsletterid,',',I) != 0 LOOP
         VAL := SUBSTR(vnewsletterid,I,INSTR(vnewsletterid,',',I)-J);
         I := INSTR(vnewsletterid,',',I)+1;
         J := I;
         INSERT INTO usersubscription (usersubcriptionid,userid,newsletterid)
         VALUES (usersubscription_seq.nextval,vuserid,VAL);
         END LOOP;
         VAL := SUBSTR(vnewsletterid,I,LENGTH(vnewsletterid));
         INSERT INTO usersubscription (usersubcriptionid,userid,newsletterid)
         VALUES (usersubscription_seq.nextval,vuserid,VAL);
    END;
    Now one requirement is that
    When next string comes like ‘1,4’ for same user
    Then I want to delete the 2 and 3 and insert the 4 .
    Please tell me solution.

    Hi,
    Try to delete all record from ther current user :
    CREATE OR REPLACE PROCEDURE usersubscription_procd (vuserid in number, vnewsletterid IN VARCHAR2)
    AS
    I NUMBER;
    J NUMBER;
    VAL VARCHAR2(100);
    BEGIN
         begin
              delete usersubscription where userid = vuserid;
         exception when others then null;
         end;
         I := 1;
         J := 1;
         WHILE INSTR(vnewsletterid,',',I) != 0 LOOP
              VAL := SUBSTR(vnewsletterid,I,INSTR(vnewsletterid,',',I)-J);
              I := INSTR(vnewsletterid,',',I)+1;
              J := I;
              INSERT INTO usersubscription (usersubcriptionid,userid,newsletterid)
              VALUES (usersubscription_seq.nextval,vuserid,VAL);
         END LOOP;
         VAL := SUBSTR(vnewsletterid,I,LENGTH(vnewsletterid));
         INSERT INTO usersubscription (usersubcriptionid,userid,newsletterid)
         VALUES (usersubscription_seq.nextval,vuserid,VAL);
    END;
    /Nicolas.

  • Delete more than 1 user from the database

    Hi All,
    I have a list of users in a file and i want to write a script to delete all these
    users from my database.
    I have tried deleting users using:
    drop user user1,user2,user3..... but it doesn't seem to work.
    Can anyone suggest how do i read the users from the file and delete them one by one

    I have written a script but getting a error.Can anyone help :-
    create or replace PROCEDURE drop_user
    is
    v_filehandle utl_file.file_type;
    v_user VARCHAR2(20);
    lv1 VARCHAR2(200);
    err_code VARCHAR2(20);
    err_msg VARCHAR2(250);
    BEGIN
    v_filehandle:=utl_file.fopen('/tmp','user_list.lst','R');
    LOOP
    BEGIN
    utl_file.get_line(v_filehandle,v_user);
    lv1:='drop user'|| v_user;
    execute immediate lv1;
    EXCEPTION
    WHEN OTHERS THEN
    err_code := SQLCODE;
         err_msg := substr(SQLERRM, 1, 200);
         dbms_output.put_line(err_code|| ':-' || err_msg);
    END;
    END LOOP;
    utl_file.fclose(v_filehandle);
    END DROP_USER;
    ERROR :
    ERROR at line 1:
    ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "SYS.UTL_FILE", line 98
    ORA-06512: at "SYS.UTL_FILE", line 157
    ORA-06512: at "TOM.DROP_USER", line 9
    ORA-06512: at line 1

  • By Java how to delete some lines in a text file containg some character?

    Hello All,
    I am having a text file [Basically It is a Sql File]. its containing some commented lines.
    All i need to do is, By using a java Method I have to delete All the commented lines in That file .....
    For Example if My file is like following.
    /**** Commented By Kannan *********/
    Select * From Employee;
    go
    /******************** Commented by Others ********/
    Select * From DevMembers;
    go
    /*** Ends here **********/
    And the output file would be
    Select * From Employee;
    go
    select * From DevMembers;
    go
    can Anyone Help me in this regards,
    Akram Kannan

    BufferedReader should probably wrap the FileReader if you will be reading line-by-line. Same with the Writer.
    And a simple -
    if (  "/*".equals(record.substring(0,1) ) ... should handle the comment locations bit.
    Message was edited by:
    abillconsl

  • How to make button to format a HardDrive or USB, How to remove all files from folder, and How to delete a process in listbox with a textbox?

    Hello!
    Here's the question with explaniation: How can i format the USB or Drive by clicking a button what's meant for it?
    and the second question what's also in vb.net: How can i remove all files from folder ? 
     Here's the Look of program: *
    Using the PC button, it will delete the free space of the PC, do you guys/girls know where it's location?

    Example Code:
    Imports System.Runtime.InteropServices
    Imports System.IO
    Public Class Form1
    Dim CBoxDrives As New ComboBox
    WithEvents FButton As New Button
    <DllImport("shell32.dll")> _
    Private Shared Function SHFormatDrive(ByVal hwnd As IntPtr, ByVal drive As UInteger, _
    ByVal fmtID As UInteger, ByVal options As UInteger) As ULong
    End Function
    Private Enum SHFormatFlags As Integer
    SHFMT_ID_DEFAULT = &HFFFF
    SHFMT_OPT_FULL = &H1
    SHFMT_OPT_SYSONLY = &H2
    SHFMT_ERROR = &HFFFFFFFF
    SHFMT_CANCEL = &HFFFFFFFE
    SHFMT_NOFORMAT = &HFFFFFFD
    SHFD_FORMAT_FULL = 0 ' full format
    SHFD_FORMAT_QUICK = 1 ' quick format
    End Enum
    Private Sub FButton_Click_1(sender As System.Object, e As System.EventArgs) Handles FButton.Click
    If CBoxDrives.Text = "" Then
    MsgBox("No Drive Selected")
    Exit Sub
    End If
    Dim Iresult As ULong = SHFormatDrive(CType(Me.Handle.ToInt32, IntPtr), CUInt(Asc(CBoxDrives.Text.Substring(0, 1)) - Asc("A")), CUInt(SHFormatFlags.SHFMT_ID_DEFAULT), 1)
    End Sub
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    Me.Size = New Size(200, 100)
    With FButton
    .Size = New Size(50, 25)
    .Location = New Point(5, 5)
    .Text = "Format"
    End With
    Me.Controls.Add(FButton)
    With CBoxDrives
    .Size = New Size(50, 25)
    .Location = New Point(75, 5)
    .DropDownStyle = ComboBoxStyle.DropDown
    End With
    Me.Controls.Add(CBoxDrives)
    Dim DrivesFound As Integer = 0
    Dim allDrives() As DriveInfo = DriveInfo.GetDrives()
    Dim d As DriveInfo
    For Each d In allDrives
    If ((d.DriveType = DriveType.Fixed) Or (d.DriveType = DriveType.Removable)) AndAlso Environment.GetEnvironmentVariable("SYSTEMROOT").StartsWith(d.Name) = False Then
    CBoxDrives.Items.Add(d.Name)
    DrivesFound += 1
    End If
    Next
    CBoxDrives.SelectedIndex = DrivesFound - 1
    End Sub
    End Class

  • How to delete the last char in a String?

    i want to delete the last char in a String, but i don't want to convert the String to a StringBuffer or an array, who knows how to do?

    Try it in this way
    String MyString = "ABCDEF";
    MyString = MyString.substring(0,MyString.length()-1);

  • Delete one guide at a time

    Hi
    any idea on how to delete/remove one guide at a time pl. I've gone through the forum which clears all the guides but couldnt find any help on deleting guides one at a time.
    Any possible solution

    Yes, with older versions you are stuck with using Action Manger to work with guides. And as far as I can tell you can't remove a single guide with AM code.
    You can remove all guides and you can create guides. I also have code that will let you get info about the current guides in a document. With that you could get the info about the guides in a document, remove all the guides, then add back the ones you want to keep. Not pretty but it should work. Here is the code.
    To get guide info:
    #target photoshop
    app.bringToFront();
    /* the info about guides can be found in the photoshop tag hex 35 42 49 4D 04 08
       the length of the tag is found at offset 11. that value is the length to the next tag
       the number of guides can be found at offset 27. From that point the data repeats
       for each guide. 4 bytes for the location. That value / 32 = pixels
       and one byte for type 0 = vert and 1 = horz
       Note: this info is just a best guess from looking at the data
    // Function: getGuideInfo
    // Description: Saves the document as a temp jpg file
    //                        and extracts the info about the guides
    //                        in document if any
    // Usage: var guides = getGuideInfo( activeDocument );
    // Input: Document
    // Return: Object: TotalCount property  = number of guides
    //                  HorizontalCount property = number of horizontal guides
    //                  VerticalCount property = number of vertical guides
    //                  Horizontal = horizontal guides
    //                  Vertical property = vertical guides
    // Source: Modified from http://ps-scripts.com/bb/viewtopic.php?t=3283
    function getGuideInfo( doc ) {
       saveOptions = new JPEGSaveOptions();
       // we don't care about image quality in the temp file
       // we do want the smallest file size
       saveOptions.quality = 0;// we don't care about image quality in the temp file
       var tempFile = new File( Folder.temp + '/' +'guideTemp.jpg' );
       // Dupe the doc, make it savable as JPEG, save it, then close the file
       doc = doc.duplicate();
       if( doc.mode == DocumentMode.BITMAP ) doc.changeMode(ChangeMode.GRAYSCALE);
       doc.bitsPerChannel = BitsPerChannelType.EIGHT;
       doc.changeMode(ChangeMode.RGB);
       doc.saveAs(tempFile, saveOptions, true);
       doc.close(SaveOptions.DONOTSAVECHANGES);
      tempFile.encoding = 'BINARY';
      tempFile.open('r');
      var str = tempFile.read();
      tempFile.close();
      tempFile.remove();
       var guideTag = '8BIM\x04\x08';
       var tagPos = str.search(guideTag);
       var guides = new Object;
       guides.toString = function(){ return 'GuideInfo'; }
       var horGuides = new Array;
       var vertGuides = new Array;
       if( tagPos != -1 ) {
          var tagLength = 12 + str.charCodeAt( tagPos + 11 );
          var guideStr = str.substring( tagPos, tagPos+tagLength );
          guides.count = str.charCodeAt( tagPos + 27 );
          var pointer = tagPos + 28;
          for( var i =0; i < guides.count; i++ ){
           //  var n = ((str[pointer] << 3) + (str[pointer+1] << 2) + (str[pointer+2] << 1) + str[pointer+3])/32;
          //var n = Number( '0x'+getHexString( str, pointer )+getHexString( str, pointer+1 )+getHexString( str, pointer+2 )+getHexString( str, pointer+3 ))/32;
                 var n = ((str.charCodeAt(pointer)<< 32) + (str.charCodeAt(pointer + 1)<< 16) +
                        (str.charCodeAt(pointer + 2) << 8) + str.charCodeAt(pointer+3))/32;
    if  (str.charCodeAt( pointer + 4 ) == 0) {
              //vertical
              vertGuides = insertValueInOrder(vertGuides, n);
           } else {
              //horizontal
              horGuides = insertValueInOrder(horGuides, n);
            // guides[ i ] =  [ (str.charCodeAt( pointer + 4 ) ? 'horz':'vert'), n ];    
             pointer = pointer + 5;
         guides.HorizontalCount =horGuides.length;
         guides.VerticalCount =vertGuides.length;
         guides.Horizontal = horGuides;
         guides.Vertical = vertGuides;
       }else{
          guides.TotalCount = 0;
         guides.HorizontalCount =0;
         guides.VerticalCount =0;
       function insertValueInOrder(a , n) {
          var b = new Array;
          var i = 0;
          if (a[0] == undefined)
             b[0] = n;
          else {
             while (a[i] < n && i < a.length) {
                   b[i] = a[i];
                   i++;
             b[i] = n;
             while (i < a.length) {
                b[i+1] = a[i];     
                i++;
          return b;
       return guides;
      function fromCharCode(input) {
          output = eval("String.fromCharCode(" + input + ")");
         return output;
    // demo
    var masterDocument = app.activeDocument;
    var guideInfo = getGuideInfo( masterDocument );
    var s = "Vertical Guides: " + guideInfo.Vertical + "\nHorizontal Guides: " + guideInfo.Horizontal;
    alert(s);
    To remove all guides:
    function clearAllGuides() {
         var desc = new ActionDescriptor();
            var ref = new ActionReference();
            ref.putEnumerated( charIDToTypeID( "Gd  " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Al  " ) );
         desc.putReference( charIDToTypeID( "null" ), ref );
         executeAction( charIDToTypeID( "Dlt " ), desc, DialogModes.NO );
    To add a guide:
    function guideLine(position, type,unit) {// from Paul MR
       //units '#Pxl' pixel '#Rlt' =Relative  '#Prc' = percent
       // types: 'Vrtc' & 'Hrzn'
        var desc = new ActionDescriptor();
            var desc2 = new ActionDescriptor();
            desc2.putUnitDouble( charIDToTypeID('Pstn'), charIDToTypeID(unit), position);
            desc2.putEnumerated( charIDToTypeID('Ornt'), charIDToTypeID('Ornt'), charIDToTypeID(type) );
        desc.putObject( charIDToTypeID('Nw  '), charIDToTypeID('Gd  '), desc2 );
        executeAction( charIDToTypeID('Mk  '), desc, DialogModes.NO );

  • Unable to delete the file. (Some times deletes and sometime fails to delet)

    Please help me in deleting the file from the temporary location .
    Below is my code
    //Append the session is with filename as there is possibility of having same name of file.
    try{
    boolean isMultipart     = ServletFileUpload.isMultipartContent(request);
              if (isMultipart)
                   // Create a factory for disk-based file items
                   factory = new DiskFileItemFactory();
                            // Create a new file upload handler
                   upload = new ServletFileUpload(factory);
                   // Parse the request
                      List /* FileItem */ items = upload.parseRequest(request);
                           // Process the uploaded items
                   Iterator iter = items.iterator();
    if(strInputFileName.lastIndexOf("\\")== -1)
         strInputFileName = (String)mPropBag.get("TempUploadDirM") + strInputFileName;
      }else
         strInputFileName = (String)mPropBag.get("TempUploadDir") +   strInputFileName.substring(strInputFileName.lastIndexOf("\\"));
    strInputFileName = strInputFileName + "_" + request.getSession().getId();
    uploadedFile     = new File(strInputFileName);
    item.write(uploadedFile);  //// I am Writing the file in this location appened with the session Id because there might //be a  possibility of having same name of file.
    catch(......)
    finally
         uploadedFile.delete();
         uploadedFile = null;
         upload = null;
    }I am unable to delete the file from the temporary location
    some times it is deleting and some times it is not deleting.. I have also tried ...deleteOnExit();

    Make sure you've got no other processes holding onto it (Windows Explorer, for instance) and that you've closed any streams involved with the file. If that fails, try calling System.gc() just before deleting the file. This is a workaround for a bug in certain JVMs on Windows machines

  • File I/O problems - renameTo() , delete()

    Hello I'm trying to access a text file here, rename it, and then create a new file of the original name. It all works, but when I'm recreating the new file the path doesn't seem to work. It just puts the file in the default directory. When I do a getAbsolutePath on the new file, it displays correctly. It seems like Java is holding on to that name after I rename it which prevents me from adding another file with the same name. Any suggestions? Also the delete of the old file doesn't seem to work.
    Thanks,
    <%@ page import="java.io.*,java.lang.*, java.util.*" %>
    <html>
    <head>
    <title>Chapter/Section Set Title Page</Title>
    </head>
    <body>
    <%
    String adjustfile = request.getParameter("adjustfile");
    String offset_s = request.getParameter("offset");
    int offset = Integer.parseInt(offset_s);
    String line_str = "";
    BufferedReader ds = null;
    FileInputStream is = null;
    File smifile = new File("/smifiles/"+adjustfile);
    File adjustfilenew = new File("/smifiles/"+adjustfile+".bac");
    smifile.renameTo(adjustfilenew);
    File newfile = new File("/smifiles/"+adjustfile); //recreating file here with original name
    BufferedWriter writer = new BufferedWriter(new FileWriter(newfile.getName(), true));
    StringBuffer data = new StringBuffer ();
    is = new FileInputStream(adjustfilenew);
    ds = new BufferedReader(new InputStreamReader(is));
    String find="<SYNC Start=";
    while ((line_str = ds.readLine()) != null)
    //System.out.println(line_str);
    //out.println(line_str);
    String addline1 = "";
    if (line_str.indexOf(find) > 0)
    int reversequack = line_str.indexOf(">");
    //out.println(reversequack);
    String timecode = line_str.substring((line_str.indexOf(find) + 12), reversequack);
    // out.println(timecode);
    int timeint = Integer.parseInt(timecode);
    int newtime = timeint + offset;
    addline1 = " <SYNC Start="+newtime+">";
    data.append(addline1);
    else {
    addline1 = line_str;
    data.append(addline1);
    String writethis = data.toString();
    writer.write(writethis);
    writer.newLine();
    data.delete(0, data.length());
    }//while close
    adjustfilenew.delete();
    ds.close();
    writer.close();
    %>
    File has been adjusted by <%=offset_s%> milliseconds.<br><br>
    Adjust timing on another file<br><br>
    Closed Caption Home
    </body>
    </html>

    Try using createNewFile() after:
    File newfile = new File("/smifiles/"+adjustfile);
    Also, close the Reader before trying to delete the backup file.
    ds.close();
    adjustfilenew.delete();
    Good luck.

  • Delete and renameto not working in java

    guys, i have written a java program that reads file1 into temp file and finally writes into another file. program is working fine with no errors, it even reported that the file is deleted. But actually the file was not deleted and renameto was never successful. could you guys see any problem with file definetion so that delete is not successful. please see code from 6th line from bottm.
    public class Mergewrs {public static void main (String[] args) throws IOException {
    /* Creates a new instance of mergewrsFile */
         /* Making sure an argument is specified */
         if(args.length > 0)
              String line           = null;
              String policyflag      = null;
              int addCnt          = 0;
              File mergein = new File("c:\\javat\\mergein.dat");
              /* Specifiying input file to be used */
              BufferedReader  inFile  = new BufferedReader(new FileReader(mergein));
              line = inFile.readLine();
              /* Read all lines in the wrsfile specified */
              while(line != null)
                   System.out.println("Process1: ");
                   policyflag      = line.substring(0,1);
                   // Reads input record from 2 thru 1025
                   String actionIndicator = new String();
                   if(policyflag != null && policyflag.equalsIgnoreCase("A"))
                        { actionIndicator = "A";
                          addCnt = addCnt+1;
                          process(actionIndicator, line);
                   catch(IOException e)
                        {System.err.println("File input error");}
                   line = inFile.readLine();
              } //while ends
         } //if ends
    public static void process(String actionIndicator, String line) throws IOException
         String line1 = null;
         String templine = null;
         String policyId = null;
         File policyOutfile = new File("c:\\javat\\mergeout.dat");
         File policyOutfileold = new File("c:\\javat\\mergeoutold.dat");
         BufferedReader  policyOut  = new BufferedReader(new FileReader(policyOutfile));
         File tempfile = new File("c:\\javat\\tempfile.dat");
         BufferedWriter tempout = new BufferedWriter(new FileWriter(tempfile));
         line1 = policyOut.readLine();
         try{
              policyId =line1.substring(150,165);
              while(line1 != null)
              {     policyId =line1.substring(150,165);
                   try
                        if(policyId.equals(line.substring(151,166)))
                             { templine =line1.substring(0,151);
                        else { templine=line1;}
                        tempout.write(templine);
                        tempout.newLine();
                        line1 = policyOut.readLine();
                   catch (Exception e) {System.err.println("File exception h");}
              } //while ends
              try { tempout.close(); }
              catch (Exception e) { e.printStackTrace();}
              try { policyOut.close(); }
              catch (Exception e) { e.printStackTrace();}
              try
                   if(policyOutfile.exists())
                        policyOutfile.delete();
                        tempfile.renameTo(policyOutfile);
              catch (Exception e) {System.out.println("error"); }
    }

    guys, i have written a java program that reads file1
    into temp file and finally writes into another file.
    program is working fine with no errors, it even
    reported that the file is deleted. But actually the
    file was not deleted and renameto was never
    successful. could you guys see any problem with file
    definetion so that delete is not successful. please
    see code from 6th line from bottm.Since you don't actually do anything with the return value how do you know it was successful?

Maybe you are looking for

  • A question about ActionListener and MouseListener

    Hi, my question here is when we should implement a MouseListener and when we should use ActionListener instead. I know ActionEvent is fired when a action performed, for instance, a button was pressed down, but I think by implementing a MouseListener,

  • ME57 - Convert Purchase Requisitions - New fields to Tree ALV in Overview?

    Hello, From ME57, one can get a list of purchase requisitions, click "Assignments," and then "Process Assignment." What next appears is a list of requisitions in a Tree ALV grid.  The title of the grid is:  "Convert Purchase Requisitions." I would li

  • Don't group ncmpcpp with terminal in dockbarX

    hi there, perhaps somebody has an idea on how to accomplish the following: i'm using mpd+ncmpcpp to listen to my music. the panel i'm using is dockbarX (dockX standalone) which groups similar windows in one single icon - just like windows' superbar.

  • MSS Employee Search - Filter option

    Hi All, Is there any way to make the filter option "ON" by default in MSS employee search component. I have checked with UI personalization in WD Java. However, it doesn't help us to fix this. Is there any way to raise the Filter event "ON" display o

  • AD Trusted Recon - Disabling user deletes him in OIM

    Hello, I'm having trouble changing a user state to 'Disabled' in OIM when I disable him in the Active Directory. Has anyone ever encountered this problem and know how to solve it? Thanks in advance