Find and edit specific line in text file?

Hello I want to read a text file that could look in some different ways since the user choose file from a list. I then want to igonre all the lines that begin with a special character, for example %. I then want to find all the lines "words" that begin with TRY for example and put those "words" in a string or array. If there is one line that contains TRY100 and anoter line that contains TRY200 I want to find those words and display them. How do i do this?

First you read the entire file.  Use the Read Text File.  Right-click on it and select the option to Read Lines.  The the count to read to -1 (read all).  You will now have an array of strings, one item for each line of your file.
Now you need to play the filter game.  I recommend using FOR loops with Autoindexing tunnels.  Assuming you are using 2012 or later, have the output autoindexing tunnels use the conditional tunnel.
Give this a try and see where you can go.  Post back with what you have tried and tell us where you are stuck.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

Similar Messages

  • How to delete and edit particular line in a file and save it in same file ?

    Hi,
    I want to delete and edit text at particular line in a file.
    But edit and delete should reflect in same file.
    I have done googling for this but it results with using another file, that i dont want as i need to save changes in same file.
    How can i do this?
    Thanks in advance
    Edited by: vj_victor on May 24, 2010 3:33 PM

    I just want to make sure, this is the only way to do what i mentioned ? or it could be done another way !a) write the data to a new file
    b) delete the old file
    c) write the data to a newer file
    d) delete the new file
    e) rename the newer file to the old file name.
    For a hint about still more ways to do this, search for the complete lyrics of One man went to mow, Went to mow a meadow...
    db

  • Write to a specific line in text file

    hi let say text file with five lines
    i need to write it in a specific line example line 3.
    how to do tht,
    thk u

    In Mike's example, you cna change the constant 2 to a control which allows ytou to select which line to write to.
    2 meaning the third position becasue indexing starts at 0. 

  • How copy just line in text file with cat? (SOLVED)

    Hi.
    How i make to copy just only line in text file with cat?
    For example:
    [:0.0]
    file=/home/Arch/./.wallpaper.png
    mode=0
    bgcolor=# 0 0 0
    I want copy just "/home/Arch/./.wallpaper.png" part.
    Actually i want create a shortcut for last wallpaper set from Nitroget, then i put this in SLim background.
    Recently i use hsetroot for wallpaper (~/.wallpaper.png) and i create a shortcut in /usr/share/slim/theme/MYTHEME whith ln -s ~/.wallpaper.png /usr/share/slim/theme/MYTHEME/background.png.
    I want make a same with Nitrogen.
    I now this looks like crazy, but...
    Sorry my English.
    Last edited by kramerxiita (2008-06-04 16:50:48)

    moljac024 wrote:
    kramerxiita wrote:
    moljac024 wrote:How can you make SliM change the background ? You link the theme background to another file ?
    Yes. In theme directory i put background.png shortcut for my wallpaper. So, when a change wallpaper, slim background change too.
    Example:
    ln -s mywallpaper.png /usr/share/slim/themes/default/background.png
    So, Slim background always is my wallpaper.
    So the wallpaper has to be a *.png ?
    No, jpg is possible. But when you create a symbolic link, remember put the extension too. If change png to jpg, change a symbolic link extension.
    But, remember if slim theme directory have background.png and background.jpg, Slim always choice .png. So, put only one this.

  • How to read specific line in a file through UNIX shell script..

    Dear Friends,
    I have generated .ldt file under admin/import/US folder through FND_LOAD script for Download the responsibility.
    I registred Shell script (Host concurrent program) in Oracle apps. Now i want to read the file in speciific line which i was generated in admin/import/US folder through unix shell script. Please help me how to read specific line and the i want to replace that which i am going to read the specific line.
    Thanks in advance..
    Regards,
    Velu.

    Hi,
    Thanks for reply,
    My requirement i have to find the specific line in a file and find and replace needed word over there it's should happen programatically. i want to read specific line in a file Once complete find and replace the condition should exists. The loop will go to next file and read the same line in next file also do the same process upto how many files over there.i am doing through UNIX shell script. Please help me out to find the
    Your suggestion is highly appriciated.
    Thanks,
    Velu.

  • How to write empty line in text file

    hey
    i want to insert one empty line in text file.
    how to write this.
    i declared
    data: emptyrec(240) type c value space,
    and used
    TRANSFER emptyrec to e_file.
    but its not inserting empty line in the record.
    is there any special way have to do.
    ambichan.

    hai anand,
    I am posting the code snippet.
    i have commented that transfer line in '----
    ' like this
    pls refer below.
    ambichan
    DATA: PAGENO(4) TYPE N VALUE 1,
          DATAKBN(2) TYPE N VALUE 1,
          SUBNO(3) TYPE N VALUE 1,
          VPAGENO(4) TYPE C,
          VDATAKBN(2) TYPE C,
          VSUBNO(3) TYPE C,
          VREC(255) TYPE C,
          VRECORD(255) TYPE C,
          EMPTYREC(255) TYPE C VALUE SPACE,
          VCODE(10) TYPE C,
          VNAME2(35) TYPE C,
          VPAYDAT(10) TYPE C,
          VSGTXT(60) TYPE C VALUE SPACE,
          VSGTXT1(10) TYPE C,
          VKINGAKU(15) TYPE C VALUE SPACE,
          VBIKKO(30) TYPE C VALUE SPACE,
          VBELNR(10) TYPE C VALUE SPACE,
          VDMBTR(15) TYPE C,
          VGLT0-KSLVT(15) TYPE C,
          VGLT0-TSL01(15) TYPE C,
          VGLT0-TSL02(15) TYPE C,
          VGLT0-TSL03(15) TYPE C,
          VGLT0-TSL04(15) TYPE C,
          VGLT0-TSL05(15) TYPE C,
          VKIN(15) TYPE C,
          VTEGA(15) TYPE C.
    FORM FRM_OUTPUT_DATA.
      SORT ITAB_OUTPUT_SUMMARY BY LIFNR DTYPE.
      SORT ITAB_OUTPUT_ITEMS   BY LIFNR DTYPE BELNR.
    IF P_DISP = 'X'."checkボクスを選ぶ場合、ファイル作成処理へ行く
    OPEN DATASET E_FILE FOR OUTPUT IN TEXT MODE.
      IF SY-SUBRC <> 0.
      WRITE: 'error',SY-SUBRC.
      EXIT.
      ENDIF.
    LOOP AT ITAB_LIFNR.
      PERFORM LISTDATA.
      PAGENO = PAGENO + 1.
      SUBNO = 1.
    ENDLOOP.
    CLOSE DATASET E_FILE."&#12501;&#12449;&#12452;&#12523;&#12463;&#12525;&#12540;&#12474;
    ENDFORM.                               " End of frm_output_data
    FORM LISTDATA.
      DATA:
        WK_PAY_AMOUNT  LIKE  BSEG-DMBTR,   " &#32020;&#25903;&#25173;&#38989;&#31639;&#20986;&#29992;
        VWK_PAY_AMOUNT(15) TYPE C,
        GLT0-TSL05_VAL LIKE GLT0-TSL05.
      READ TABLE ITAB_OUTPUT_SUMMARY
             WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 1.
    BSIK-DMBTR  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      GLT0-TSL01  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      READ TABLE ITAB_OUTPUT_SUMMARY
             WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 2. " &#21306;&#20998;&#65306;2
      GLT0-TSL02  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      READ TABLE ITAB_OUTPUT_SUMMARY
             WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 3. " &#21306;&#20998;&#65306;3
      GLT0-TSL03  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      READ TABLE ITAB_OUTPUT_SUMMARY
             WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 4. " &#21306;&#20998;&#65306;4
      GLT0-TSL04  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      READ TABLE ITAB_OUTPUT_SUMMARY
             WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 5. " &#21306;&#20998;&#65306;5
      GLT0-TSL05  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
    glt0-tsl05  =  glt0-tsl05  +  glt0-tsl04.
      WK_PAY_AMOUNT  =  GLT0-TSL05  +  GLT0-TSL04.
    CHECK WK_SUBRC = 0.                
      BSEG-KOART = ' '.                    &#24773;&#22577;&#19981;&#35201;
      CLEAR: BSEG-SGTXT, BSEG-DMBTR, TGSBT-GTEXT, BKPF-BELNR.
      BSEG-KOART = 'Y'.                    " &#12501;&#12521;&#12464;&#65306;&#12504;&#12483;&#12480;&#12395;&#30456;&#27578;&#38989;&#12434;&#20986;&#21147;
    CLEAR: BSAK-DMBTR.
      READ TABLE ITAB_OUTPUT_SUMMARY
           WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 6.  " &#21306;&#20998;&#65306;6
      BSAK-DMBTR  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      WK_PAY_AMOUNT  =  WK_PAY_AMOUNT  -  BSAK-DMBTR.
      WRITE : / PAGENO,
               SUBNO,
               DATAKBN,
               ITAB_LIFNR-LIFNR,
               ITAB_LIFNR-NAME2(25),
               P_PAY_T,
               GLT0-TSL01,
               GLT0-TSL02,
               GLT0-TSL03,
               GLT0-TSL04,
               GLT0-TSL05.
    VPAGENO = PAGENO.
    VSUBNO = SUBNO.
    DATAKBN = 1.
    VDATAKBN = DATAKBN.
    VCODE = ITAB_LIFNR-LIFNR.
    VNAME2 = ITAB_LIFNR-NAME2.
    VPAYDAT = P_PAY_T.
    VGLT0-TSL01 = GLT0-TSL01.
    VGLT0-TSL02 = GLT0-TSL02.
    VGLT0-TSL03 = GLT0-TSL03.
    VGLT0-TSL04 = GLT0-TSL04.
    VGLT0-TSL05 = GLT0-TSL05.
    CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT VKINGAKU
    VBIKKO VBELNR VGLT0-TSL01 VGLT0-TSL02 VGLT0-TSL03
    VGLT0-TSL04 VGLT0-TSL05 INTO VREC SEPARATED BY ','.
    CLEAR: BSAK-DMBTR, BSID-DMBTR, BSAD-DMBTR, BSEG-DMBTR, BSIK-DMBTR,
             WK_10 , WK_11 , GLT0-TSL05.
      READ TABLE ITAB_OUTPUT_SUMMARY
           WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 7.  " &#21306;&#20998;&#65306;7
      BSID-DMBTR  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      WK_PAY_AMOUNT  =  WK_PAY_AMOUNT  -  BSID-DMBTR.
    &#37109;&#36865;&#26009;&#12398;&#20986;&#21147;&#20966;&#29702;
      READ TABLE ITAB_OUTPUT_SUMMARY
           WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 8.  " &#21306;&#20998;&#65306;8
      BSAD-DMBTR  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      WK_PAY_AMOUNT  =  WK_PAY_AMOUNT  -  BSAD-DMBTR.
      READ TABLE ITAB_OUTPUT_SUMMARY
           WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 9.  " &#21306;&#20998;&#65306;9
      BSEG-DMBTR  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      WK_PAY_AMOUNT  =  WK_PAY_AMOUNT  -  BSEG-DMBTR.
      READ TABLE ITAB_OUTPUT_SUMMARY
             WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 10.
      WK_10 =     ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      READ TABLE ITAB_OUTPUT_SUMMARY
             WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 11.
      WK_11 =     ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      GLT0-TSL05  =   WK_PAY_AMOUNT - WK_10 - WK_11.
      WK_PAY_AMOUNT  =  WK_PAY_AMOUNT  -  GLT0-TSL05.
       VWK_PAY_AMOUNT = WK_PAY_AMOUNT.
       VKIN = WK_10.
       VTEGA = WK_11.
       CONCATENATE VREC VWK_PAY_AMOUNT VKIN VTEGA INTO
             VRECORD SEPARATED BY ','.
       TRANSFER VRECORD TO E_FILE.
        WRITE :
                VWK_PAY_AMOUNT,
                WK_10,
                WK_11.
       WRITE:/.
      BSEG-KOART  = 'X'.                   " &#12501;&#12521;&#12464;&#65306;&#35531;&#27714;&#37329;&#38989;&#12434;&#20986;&#21147;
      LOOP AT ITAB_OUTPUT_ITEMS WHERE LIFNR = ITAB_LIFNR-LIFNR
                                AND   DTYPE = 5.          " &#21306;&#20998;&#65306;5
        BSEG-SGTXT   =  ITAB_OUTPUT_ITEMS-SGTXT.          " &#26126;&#32048;&#12486;&#12461;&#12473;&#12488;
        GLT0-KSLVT   =  ITAB_OUTPUT_ITEMS-DMBTR * WK_RATIO.     " &#37329;&#38989;
        TGSBT-GTEXT  =  ITAB_OUTPUT_ITEMS-GTEXT.              BKPF-BELNR   =  ITAB_OUTPUT_ITEMS-BELNR.         
       SUBNO = SUBNO + 1.
       VSUBNO = SUBNO.
       DATAKBN = 2.
       VDATAKBN = DATAKBN.
       VGLT0-KSLVT = GLT0-KSLVT.
       VBIKKO = TGSBT-GTEXT.
       VBELNR = BKPF-BELNR.
       VSGTXT1 ='&#35531;&#27714;&#37329;&#38989;:'.
       CLEAR VRECORD.
      CONCATENATE  VSGTXT1 BSEG-SGTXT INTO VSGTXT.
      CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT
    VGLT0-KSLVT VBIKKO VBELNR INTO VRECORD SEPARATED BY ','.
      TRANSFER VRECORD TO E_FILE.
       WRITE :/ VPAGENO,VSUBNO,VDATAKBN,'&#35531;&#27714;&#37329;&#38989;:', VSGTXT, VGLT0-KSLVT,
                VBIKKO,VBELNR.
      ENDLOOP.
      CLEAR: BSEG-SGTXT,GLT0-KSLVT,BKPF-BELNR.
    LOOP AT ITAB_OUTPUT_ITEMS WHERE LIFNR = ITAB_LIFNR-LIFNR
                                AND   DTYPE = 6.          " &#21306;&#20998;&#65306;6
        BSEG-SGTXT   =  ITAB_OUTPUT_ITEMS-SGTXT.          " &#26126;&#32048;&#12486;&#12461;&#12473;&#12488;
        IF  ITAB_OUTPUT_ITEMS-SHKZG  =  CNS_CREDIT.       " &#37329;&#38989;
          GLT0-KSLVT  =  ITAB_OUTPUT_ITEMS-DMBTR * WK_RATIO.
        ELSEIF  ITAB_OUTPUT_ITEMS-SHKZG  =  CNS_DEBIT.
          GLT0-KSLVT  =  ITAB_OUTPUT_ITEMS-DMBTR * WK_RATIO * -1.
        ENDIF.
      TGSBT-GTEXT  =  ITAB_OUTPUT_ITEMS-GTEXT.          " &#20107;&#26989;&#38936;&#22495;&#12486;&#12461;&#12473;&#12488;
      BKPF-BELNR   =  ITAB_OUTPUT_ITEMS-BELNR.          " &#20253;&#31080;&#30058;&#21495;
      SUBNO = SUBNO + 1.
      VSUBNO = SUBNO.
      DATAKBN = 3.
      VDATAKBN = DATAKBN.
      VGLT0-KSLVT = GLT0-KSLVT.
      VBIKKO = TGSBT-GTEXT.
      VBELNR = BKPF-BELNR.
      VSGTXT1 ='&#30456;&#27578;&#37329;&#38989;:'.
      CLEAR VRECORD.
      CONCATENATE  VSGTXT1 BSEG-SGTXT INTO VSGTXT.
      CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT
      VGLT0-KSLVT VBIKKO VBELNR INTO VRECORD SEPARATED BY ','.
      TRANSFER VRECORD TO E_FILE.
    concatenate vpageno vsubno vdatakbn
      WRITE :/ PAGENO,SUBNO,DATAKBN,'&#30456;&#27578;&#37329;&#38989;',BSEG-SGTXT, GLT0-KSLVT,
             TGSBT-GTEXT, BKPF-BELNR.
      ENDLOOP.
       CLEAR VRECORD.
    *Insert empty line.
      TRANSFER EMPTYREC TO E_FILE.
      DATAKBN = 3.
      VDATAKBN = DATAKBN.
      SUBNO = SUBNO + 1.
      VSUBNO = SUBNO.
      VSGTXT ='&#28304;&#27849;&#37329;&#38989;'.
      VDMBTR = BSID-DMBTR.
      CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT
      VDMBTR INTO VRECORD SEPARATED BY ','.
      TRANSFER VRECORD TO E_FILE.
      WRITE :/ PAGENO, SUBNO,DATAKBN, ITAB_LIFNR-LIFNR,ITAB_LIFNR-NAME2,
             P_PAY_T,'&#28304;&#27849;&#37329;&#38989;', BSID-DMBTR.
      CLEAR: VDMBTR, VSGTXT, VRECORD.
      SUBNO = SUBNO + 1.
      VSUBNO = SUBNO.
      VSGTXT = '&#37109;&#36865;&#26009;'.
      VDMBTR = BSAD-DMBTR.
      CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT
      VDMBTR INTO VRECORD SEPARATED BY ','.
      TRANSFER VRECORD TO E_FILE.
      WRITE :/ PAGENO, SUBNO,DATAKBN,ITAB_LIFNR-LIFNR,ITAB_LIFNR-NAME2,
             P_PAY_T,'&#37109;&#36865;&#26009;', BSAD-DMBTR.
      CLEAR: VDMBTR, VSGTXT, VRECORD.
      SUBNO = SUBNO + 1.
      VSUBNO = SUBNO.
      VSGTXT = '&#25391;&#36796;&#12415;&#25163;&#25968;&#26009;'.
      VDMBTR = BSEG-DMBTR.
      CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT
      VDMBTR INTO VRECORD SEPARATED BY ','.
      TRANSFER VRECORD TO E_FILE.
      CLEAR: VDMBTR, VSGTXT, VRECORD.
      WRITE :/ PAGENO,SUBNO,DATAKBN,ITAB_LIFNR-LIFNR,ITAB_LIFNR-NAME2,
            P_PAY_T,'&#25391;&#36796;&#12415;&#25163;&#25968;&#26009;',BSEG-DMBTR.
    *&#12381;&#12398;&#20182;&#12398;&#25903;&#25173;&#12356;&#12398;&#20966;&#29702;
      SUBNO = SUBNO + 1.
      VSUBNO = SUBNO.
      VSGTXT = '&#12381;&#12398;&#20182;&#12398;&#25903;&#25173;&#12356;'.
      VDMBTR = GLT0-TSL05.
      CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT
      VDMBTR INTO VRECORD SEPARATED BY ','.
      TRANSFER VRECORD TO E_FILE.
      WRITE :/ PAGENO,SUBNO,DATAKBN,ITAB_LIFNR-LIFNR,ITAB_LIFNR-NAME2,
            P_PAY_T, '&#12381;&#12398;&#20182;&#12398;&#25903;&#25173;&#12356;',GLT0-TSL05.
                                     glt0-tsl05.
    ULINE.
    CLEAR: VREC, VRECORD,VCODE,VNAME2,VPAYDAT,VSGTXT,VSGTXT1,VKINGAKU.
    CLEAR: VBIKKO,VBELNR,VDMBTR,VGLT0-KSLVT,VGLT0-TSL01,VGLT0-TSL02.
    CLEAR: VGLT0-TSL03,VGLT0-TSL04,VGLT0-TSL05,VKIN,VTEGA,VWK_PAY_AMOUNT.
    ENDFORM.

  • Read lines from text file to java prog

    how can I read lines from input file to java prog ?
    I need to read from input text file, line after line
    10x !

    If you search in THIS forum with e.g. read lines from file, you will find answers like this one:
    Hi ! This is the answer for your query. This program prints as the output itself reading line by line.......
    import java.io.*;
    public class readfromfile
    public static void main(String a[])
    if you search in THIS forum, with e.g. read lines from text file
    try{
    BufferedReader br = new BufferedReader(new FileReader(new File("readfromfile.java")));
    while(br.readLine() != null)
    System.out.println(" line read :"+br.readLine());
    }catch(Exception e)
    e.printStackTrace();
    }

  • When i use view as list in finder and open a folder with many files i cant right click with mouse without selecting or highlighting a file....i just want to right click to paste an item or create a new folder...what can i do?

    When i use view as list in finder and open a folder with many files i cant right click with mouse without selecting or highlighting a file....i just want to right click to paste an item or create a new folder...what can i do?

    Thx for that im gonna try it....but is there a way to do it without using toolbar or cmd-c...? i mean using only the mouse?why does it have to highlight the file even though i click a bit next to it....?using icon view i can right click next to the folder and i wont have a problem but with list view that i prefer using it will highlight the whole row.....and i dont find free space to right click cause i got many files

  • Create and write form output to text file

    HI am pretty new to this and have a prob.
    I have 10 fields in my form submitting which i need to create and write the form field values into an xml fil..this file is further used for other read write transactions.
    Can somebody help creating and writing data into the text file with code (if u have it handy).
    Thanks for the help in anticipation

    File f = new File("/path/to/output.txt");
    BufferedWriter bw = new BufferedWriter(new FileWriter(f));
    String inputData = null;
    while(true){
      inputData = //whatever data you need
      bw.write(inputData);
    bw.flush();
    bw.close();
    f.close;
    // All this should be in a try{}catch(IOException ioe){}

  • How to store ,retreive and edit  data from an xml file

    I am new to XML. I am creating a phone book in JSP with backend as an XML file.How can I store retrieve and edit datas from a jsp file.
    Please provide me with examples.I dont want to use bean.
    Please provide examples

    You will have to do some leg-work yourself. You will probably want to use DOM to parse and manipulate your XML data. Xerces (xml.apache.org) is a good open source parser. There are extensive examples on their site.
    - Saish

  • I recently switched from PC to Mac and am able to find and transfer most of the larger files of music to iTunes, but there are about 750 songs that are held in sub-files that require me to dig in and transfer them one by one to iTunes.. I've tried transfe

    I recently switched from PC to Mac and am able to find and transfer most of the larger files of music to iTunes, but there are about 750 songs that are held in sub-files that require me to dig in and transfer them one by one to iTunes.. I've tried transferring the parent folders, but it doesn't seem to work.  Does anyone know of a more efficient way of getting iTunes to dig into the subfolders and transfer the music without me having to go one by one?

    There is a good general guide to switching from Windows to Mac at the following link that touches on moving music as well How to Move to a Mac - Get your stuff from your PC to your new Mac
    There are also these guides:
    How to move music between authorised computers
    Networking with a Windows PC
    Don't forget to deauthorise your old PC if you are disposing of it so you don't use up your 5 allowances: About iTunes Music Store Authorisation and Deauthorisation

  • Find and replace a line in a text  file

    Hi All,
    I wanted to read a text file , find a line and replace that line with out affecting any other lines and with out creating a new file.
    If any one of you know any API to do this work ,please throw some light

    This seems to be a question on optimal implementation of search and replace.
    For replacing text in the file itself, the sought text and replaced text must be the same length,
    as inserting a character somewhere in a file, is better done in a new file.
    You could do this with a java.io.RandomAccessFile[b].
    The new IO package [b]java.nio provides a memory mapped file which is faster.
    The following code does such patching.
    import java.io.*;
    import java.nio.*;
    import java.nio.channels.*;
    public class Patch {
        private static byte[] sought;
         private static byte[] replacement;
         private static boolean matches(MappedByteBuffer bb, int pos) {
              for (int j = 0; j < sought.length; ++j)
                   if (sought[j] != bb.get(pos + j))
                        return false;
              return true;
         private static void replace(MappedByteBuffer bb, int pos) {
              for (int j = 0; j < sought.length; ++j)
                   byte b = (j < replacement.length)? replacement[j] : (byte)' ';
                   bb.put(pos + j, b);
         private static void searchAndReplace(MappedByteBuffer bb, int sz) {
              int replacementsCount = 0;
              for (int pos = 0; pos <= sz - sought.length; ++pos)
                   if (matches(bb, pos)) {
                        replace(bb, pos);
                        pos += sought.length - 1;
                        ++replacementsCount;
              System.out.println("" + replacementsCount + " replacements done.");
        // Search for occurrences of the input pattern in the given file
        private static void patch(File f) throws IOException {
              // Open the file and then get a channel from the stream
              RandomAccessFile raf = new RandomAccessFile(f, "rw"); // "rws", "rwd"
              FileChannel fc = raf.getChannel();
              // Get the file's size and then map it into memory
              int sz = (int)fc.size();
              MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_WRITE, 0, sz);
              searchAndReplace(bb, sz);
              bb.force(); // Write back to file, like "flush()"
              // Close the channel and the stream
              raf.close();
        public static void main(String[] args) {
              if (args.length == 0)
                   args = new String[] { "row ", "item", "2.xml" };
              if (args.length < 3) {
                   System.err.println("Usage: java Patch sought replacement file...");
                   return;
              sought = args[0].getBytes();
              replacement = args[1].getBytes();
              if (sought.length != replacement.length) {
                   // Better build-in some support for padding with blanks.
                   System.err.println("Usage: sought (" + args[0] + ") and replacement (" + args[1] + ") must have same length");
                   return;
              for (int i = 2; i < args.length; i++) {
                   File f = new File(args);
                   try {
                        patch(f);
                   } catch (IOException x) {
                        System.err.println(f + ": " + x);

  • Removing first line in text file... Memory and HD concern

    Hello all,
    I want to remove the first line of a text file. This is easy... One way
    to do it, is to find the first "end of line" caracter, strip the string
    and re-write the sting in file with the "strip to sreadsheet" VI.
    Since the file can be quite large (about 120000 lines), is this a good
    way to do it. Will it re-write all the line or just moving the "begin
    of file" pointer to the second line? If it re-write the whole file,
    this option is not very good since I could have to do this operation
    quite often. (I want the file to be a kind of circular buffer / backup).
    What do you think is the best way to do this?
    Thanks!
    Vincent

    I think you would have to read in all the data and write it to a new file, you could either keep the data in RAM or simply write to another file then delete the original, and then rename the temp one.  So obviously that is a lot of data and memory.
    My main question is are you trying to use a text file as a circular buffer?  If so can you tell us more about the data, ie is it strings of a constant length?  Does a user ever need to read the file or could we head binary?
    A solution would be to truly make the file a binary file, so you could actually seek through the file easier, and maybe make the first data chunk the location of the most recent write.  The obvious danger is then writing over existing data.  This solution is still risky because of the data writes.
    You may want to look at some of the other file formats like HWS which maintains a hierarchy of data for you so you can simply add and remove data from it.  However, a user will not be able to easily read it.

  • Find and Replace multiple line PHP comment

    Greeting everyone!
    Hopefully this question is asked in the right place.
    I have about 300 php files that have multiple line PHP
    comment that start with /* and end with this */. I want to remove
    all the comments since I am trying to reduce the file size as much
    as possible. The comments are no longer needed and I have tried
    many different configureation in the dreamweaver find and replace,
    but for the life of me I cannot seem to get it to work. I even
    tried useing regular expressions, but the astrick * is a wild card
    the the code tags contain an astrick.
    Is it possible to do this in dreamweaver, or will I need to
    hand edit every page?
    Thank for help
    example

    I am not sure of the exact syntax but open the find replace
    function on a page and play with find syntax search feature from
    the drop down menu . If I am not mistaken you should be able to to
    search from the beginning of a comment tag to the end of one and
    grab whats in between. From the help file
    Use the Find And Replace dialog box to search for text or
    tags in a document, and to replace the found material with other
    text or tags.
    Select Edit > Find And Replace.
    In the Search pop‑up menu, select Specific Tag.
    Select a specific tag or [any tag] from the pop‑up menu
    next to the Search pop‑up menu, or type a tag name in the
    text box.
    (Optional.) Limit the search with one of the following tag
    modifiers:
    With Attribute Specifies an attribute that must be in the tag
    for it to match. You can specify a particular value for the
    attribute or select [any value].
    Without Attribute Selects an attribute that must not be in
    the tag for it to match. For example, select this option to search
    for all img tags with no alt attribute.
    Containing Specifies text or a tag that must be contained
    within the original tag for it to match. For example, in the code
    <b><font size="4">heading 1</font></b>, the
    font tag is contained within the b tag.
    Not Containing Specifies text or a tag that must not be
    contained within the original tag for it to match.
    Inside Tag Specifies a tag that the target tag must be
    contained in for it to match.
    Not Inside Tag Specifies a tag that the target tag must not
    be contained in for it to match.
    (Optional.) To limit the search further, click the Plus (+)
    button and repeat step 3.
    If you didn’t apply any tag modifiers in steps 3 and 4,
    then click the Minus (-) button to remove the tag modifiers
    pop‑up menu.
    If you want to perform an action when the tag is found (such
    as removing or replacing the tag), select the action from the
    Action pop‑up menu and, if applicable, specify any additional
    information necessary to perform the action.

  • Reading multiple text files and writing them to one text file

    Hi,
    I'm trying to read a number of text files and write them to a single master file. My program reads all the files but only writes the last one to the master file.
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    // Input/Output Classes
    import java.util.Scanner;
    import java.io.PrintWriter;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.FileNotFoundException;
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    import javax.swing.JTextArea;
    import java.awt.GridLayout;
    public class Actor implements ActionListener
    public static String DataRoot = "I:\\JAVA\\UBP\\DAT
    public static JFrame SW = new JFrame();
    public static JTextField txtSPath;
    public static JTextArea txtTable;
    public void actionPerformed( ActionEvent e )
    String Command = e.getActionCommand();
    if (Command.equals("Process") )
    SetupWin();
    ProcessAll();
    public void SetupWin()
    SW.setTitle("void");
    SW.setSize(300,400);
    SW.setLayout(new GridLayout(6,1));
    txtSPath = new JTextField(40);    SW.add(txtSPath);
    txtTable = new JTextArea(10, 40); SW.add(txtTable);
    SW.setVisible(true);
    public void ProcessAll()
    Process("Dunstable","Finance");
    Process("Dunstable","Production");
    Process("Dunstable","Sales");
    public void Process(String Town, String Dept)
    String SPath = DataRoot + Town + "
    " + Dept + ".txt";
    String MPath = DataRoot + "masterFile" + ".txt";
    txtSPath.setText(SPath);
    String message = "Trying  " + SPath;
    System.out.println(message);
    String SlaveTable=message;
    try// if following fails an exception is thrown
    Scanner Slave = new Scanner(new FileInputStream(SPath)); // reads slave file
    PrintWriter outputStream = null;
    outputStream = new PrintWriter(new FileOutputStream(MPath));
    while ( Slave.hasNextLine() ) // reads text line by line
    //Read and output next record
    String PartRecord  = Slave.nextLine();
    String FullRecord = Town + " " + PartRecord;
    System.out.println(FullRecord);
    outputStream.println(FullRecord);
    Slave.close();
    outputStream.close();
    txtTable.setText(SlaveTable);
    //An Exception Error would be THROWN by above & CAUGHT below
    catch(FileNotFoundException e)
    message = "Could Not Find " + SPath;
    System.out.println(message);     //console
    txtSPath.setText(message);     //window
    catch(IOException e)
    System.out.println("Slave I/O Problem " + SPath);
    }Edited by: Ardour on Mar 4, 2008 1:53 PM

    I haven't looked closely, but my spidey sense tingles at this:
    new FileOutputStream(MPath)This will clobber (erase) the previous contents of the file. Open in append mode:
    new FileOutputStream(MPath, true)Of course, if the file exists before you run this code, you will end up append to the original contents. If that is not wanted, consider using File's delete method first.

Maybe you are looking for