Replace line in file

Hi,
does anybody know how to replace one line in a file with another line? I want to change only one line in a file and do not know how i can do it.
Greetings.

Would both the old and new lines be the samelength?
No, they differ in length.Then you can't do it without create a whole new file.
Read the old file.
Spit the content of the old file into a new one.
When you get to the line you want to change put the new line in instead of the old one...
Continue on copying the lines from old to new.
You CAN replace content in a file but if they have different length's you are SOL.

Similar Messages

  • How to replace a line in file Java

    Hi,
    I want to replace a line in file sequencial.
    I read file, but i don't know how to replace one line..
    Thanks...

    I supose this..
    I usea a FileReader and BufferedReader to read a file.
    I read a line, I know the number of the line, but how to say to method println o write what it's the line to replace?

  • How do I replace one video file with another

    Hey all
    I'm new to Imovie, so please bare over with me.
    I made a long movie using a MOD format file from my JVC home camera
    When I where to convert or burn the movie in Imovie it made an error.
    After much trouble I found out that it was the MOD format that was the problem
    So I bought an expensive piece of software that converted the MOD file to MOV:
    And with a new test project it now works flawless...
    Anyways back to the original project and the problem:
    - I have now converted the original MOD file to MOV
    - I have the original Imovie project with the MOD file.
    How do I replace the mod file in the imovie project with the new mov file, while keeping, that is transfering all my work on the mod file over to the new mov file?
    Thnx
    Kris

    • In the Layers Panel draw the Layer’s Vector Mask icon onto the trashcan-icon
    • move that Layer above the new Text Layer
    • invoke Create Clipping Mask (command-alt-G) from Layers Panel’s fly-out menu or alt-click on the line separating the two Layers’ icons

  • Can't Replace (Relink) AIFF files with anything.

    Hi there,
    using FCPx 10.0.9 on 64 bit iMac which runs like a top. 
    I used some AIFF's in a session before experiencing and confirming here that even when using optimized media, they upset our finicky FCPX.   I converted the files to WAVs used relink (and create optimized media again) to replace them, and everything was fine. 
    Somehow the files have become unlinked.  The Event Browser files still show as AIF files in the Event Browser (and in the Relink dialogue window,) and when I try to relink them to the WAV versions, it *seems* to work at first.  The progress bar for "Confirming compatible format type" or whatever finishes quickly & disappears, then the file name is no longer in the Relink window.  Great right?
    Only nothing has changed in the Event Browser or Timeline.  I seem to have trashed the original AIF files once the WAV's worked, but I have even tried converting the WAVs *back* to AIFF's and tried to relink to those just to see if relink worked at all, and yeah, no. 
    Totally stumped, and a bit worried.  Any suggestions?
    Thanks,
    Brian

    Doing "Show in Finder" for the AIFF files brings up aliases in the Event's Original Media Folder.   Based on some file path remnants it's now looking like I actually imported the AIFF's (converted in iTunes from mp3's)  directly from an iTunes folder in which I created them (and tagged them as a single album,) whereas I thought I had imported them as optimized media.  That would confirm why the AIFF's were wonky.  Anyway those files / album / folder have been deleted through iTunes, which I would have done assuming the WAV's were securely in their place.
    The WAV'es *were* imported with optimized media setting, as evidenced by the real files - not aliases - being in the Original Media folder.  (WAV's originally created in iTunes before optimized import.)
    So yes WAV versions are in broswer and fully available.  How would I replace the AIF files with the WAV's, I assumed relink was the way to do that.  Or do you mean replace the edit pieces in time line.   I don't know how I would do that to get all the time codes to match - dropping the full clip over the edit piece gives a number of options but I don't think any will replace with same in and out time code, unless I'm mistaken.   Also I would like to confirm that my Relink can still be functional.
    I did try one more thing, which was to delete one of the WAVs from the Event, then trying again to link to it again  - thinking maybe the AIFF couldn't link to it because it was already associated with a clip in the Event.   It didn't work.   Also if it had it wouldn't explain why when I try to link to a newly created AIFF version, it will not link to that either, despite identical file names.  

  • Does CallerLineNumberAttribute replace #line directive?

    My understanding to
    #line directive  is to hardcode the line number in the code. But since after .net 4.5, we have
    CallerLineNumberAttribute.
    Can we ignore #line directive and mark it as a legacy skill?

    I am not sure if I understand your question properly but the #line directive lets you modify the
    compiler's line number.
    The CallerLineNumberAttribute allows you to obtain the line number in the source file at which the method is called at runtime. This not the same thing.
    So I guess the answer to your questions is: No, the CallerLineNumberAttribute does not replace #line.
    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question.

  • Replace line feed with perl

    I'm trying to replace 'line feed & space' with a line feed:
    perl -pi -e 's/\n /\n/g' ~/Desktop/scrap
    With no luck. Any help?

    I'm guessing this is related to line endings. If the file has legacy mac line endings it will behave as a single line. Try running the following. If it reports 0, then you'll need to convert the line endings:
    <pre style="border: 1px solid #ddd; padding-left: .75ex; padding-top: .25em; padding-bottom: .25em; margin-top: .5em; margin-bottom: .5em; margin-left: 1ex; max-width: 25ex; overflow: auto; font-size: 10px; font-family: Monaco, 'Courier New', Courier, monospace; color: #444; background: #eee; line-height: normal">wc -l < ~/Desktop/scrap</pre>
    The following will convert old mac line endings (as well as windows) to unix:
    <pre style="border: 1px solid #ddd; padding-left: .75ex; padding-top: .25em; padding-bottom: .25em; margin-top: .5em; margin-bottom: .5em; margin-left: 1ex; max-width: 40ex; overflow: auto; font-size: 10px; font-family: Monaco, 'Courier New', Courier, monospace; color: #444; background: #eee; line-height: normal">perl -pi -e 's/\r\n?/\n/g' ~/Desktop/scrap</pre>

  • Deleting first line off file

    Hello,
    I want to remove the first line of a file. Is there any way to do that
    without reading the whole file and putting it in a huge string?
    Something like setting the "begining of file marker" (does that
    exist?). I've looked in the "advanced file function" and can't find a
    way to do it.
    Any suggestion?
    Thanks a lot!!
    Vincent

    I don't see any Read File by Lines vi in LV7.1.  Maybe it exists in LV 8.  However there is a Read Lines from File vi but it does not produce an array of lines (at least not in LV 7.1).  You can use the Read Lines from File vi and set the number of lines to 1.  The output mark after read is now set to point to the second line.  You can use this as an input to start of read offset on your next read call.  This vi will open the file, read, then close the file.  Calling it a second time will open the file again, read, then close again.
    Another way is to open the file using Open/Create/Replace File.  Then use Read File and set the Line Mode input to True.  This will read the first line.  A second Read File call will then begin reading at the second line without having to wire any offsets.  After reading all that you want, you close the file.  One open, several reads, one close.  This is more efficient.
    Message Edited by tbob on 03-06-2007 03:03 PM
    - tbob
    Inventor of the WORM Global
    Attachments:
    ReadLines.png ‏4 KB

  • Replace an existing file with a new one

    This is probably a very simple problem. I have a script that is making an XML document. I am sucking information out of a database and exporting it as a XML file. The script runs just dandy except when I want to update the text file I receive an error along the lines of "the file already exists".
    What code do I use to replace an existing file?
    tell application "Finder"
    set theFile to "donky.xml" as string
    set theFullName to mySavePathAsText & theFile
    set theNewFile to make new file at myPath with properties {name:theFile}
    write myFinalText to file theFullName
    set the extension hidden of theNewFile to false
    end tell
    I assume I would use the "replacing yes" command but that is not working or I am not doing it right.
    Any help much appreciated.

    Hello
    Two things.
    • 'open for access file _path with write permission' will create new file at the path given in _path if it's not present.
    • 'set eof' command will clear the existing contents of the given file, which lets you replace the contents.
    So you may try something like this. (Finder is only used to set 'extension hidden' property of the file)
    Good luck
    H
    -- SNIPPET
    set theFileName to "donky.xml"
    set theFullPath to mySavePathAsText & theFileName
    try
    set fref to open for access file theFullPath with write permission
    set eof fref to 0 -- clear the existing contents
    write myFinalText to fref starting at eof
    close access fref
    on error errs number errn
    try
    close access file theFullPath
    on error --
    end try
    error errs number errn
    end try
    tell application "Finder"
    set extension hidden of item theFullPath to false
    end tell
    -- END OF SNIPPET

  • Replace layered photoshop file?

    I have a large photoshop file (about 40 layers) that i'd like to replace with another photoshop layered file (which contains the exact # of layers with the same naming convention, although each has a different image).
    Currently the only way of replacing a layered file is to select each individual layer and  search for that layer in another file.
    How  can this be done?
    Thanks
    Jeff

    ...the way you are already doing it. Sorry, there is no automated way to do this. AE doesn't care for a PSDs internal structure once the layers have been imported. to the program it's al ljust footage. that's good on most days as it prevents misconduct with screwy PSD files, bad on days when you need to replace things. Since the layers are named identically, a script might be of help. Perhaps something along those lines is floating around on AEnhancers or AEScripts...
    Mylenium
    Wait, what?
    That's exactly how after effects deals with photoshop files, it looks for file name then layer name, it does not arbitrarily convert it to some new footage type.  As long as the shell of the photoshop file is the same (filename, number of layers, and layer names), then the AEP, placed in the directory relative to the PSD will update with WHATEVER those current images are.
    Sorry to disagree here, Mylenium, and you obviously have a lot of posts and have likely helped many many people, but I think this response is just plain wrong.  I even went so far as to triple check doing a quick test, and the AEP/PSD combination behaved as i expected it to.  And you would get misconduct from messing with the PSD.  Try changing a layer name in photoshop and saving it, then opening you AEP and see what happens (the dreaded color bars).
    As for your problem, Jeff, since you can't just copy and replace the old file due to the need to keep it plus the new one, your best bet is to import the PSD as a comp, and then alt+drag the individual layers from the project palette to the selected layers that need replacing.  This will keep all of your keyframes and whatnot.
    OR
    Maybe you create two separate directories, one with the old and one with the new PSD, and set two separate AEP's up the way you want them, then combine those directories and import one of the AEP's into the other (I love the fact that you can import an AEP into an AEP...has saved my butt MANY times).  That might be the ticket right there.
    I hope maybe that helps

  • I had two files named graphics and I replaced one graphics file with another which was the wrong one.  Can I undo my replacement?  I move the wrong one, which was on my desktop into another one and that is when it as me if I wanted to replace the file.

    I accidently replaced a file with another.  Can I undo my action? 
    I had two files named graphics.  One was on my desktop and another was within another file called solitarie.  I move the one on my desktop (wrong file) into the solitarie file and was asked if I wanted to replace the graphics file in the solitarie folder (the correct one).  I said yes accidently and then remembered that I had made a mistake.  If I use undo, it only move the wrong file back to the desktop.  Is there an undo of replace?

    Sorry, but's that's why you get the warning. "Replace" means just that - the new file over-writes the old one. There is no undo.

  • How to transfer file from ipod touch to i tunes. i have files in my ipod , ut itunes is  new so its telling if u sync the ipod all the files will be replaced but no files in the itunes.. so kindly help me how to transfer the files  from i pod to itunesb

    how to transfer file from ipod touch to i tunes. i have files in my ipod , ut itunes is  new so its telling if u sync the ipod all the files will be replaced but no files in the itunes.. so kindly help me how to transfer the files  from i pod to itunes......

    Some of the information below has subsequently appeared in a document by turingtest2: Recovering your iTunes library from your iPod or iOS device - https://discussions.apple.com/docs/DOC-3991
    Your i-device was not designed for unique storage of your media. It is not a backup device and media transfer was designed for you maintaining a master copy of your media on a computer which is itself properly backed up against loss. Syncing is one way, computer to device, updating the device content to the content on the computer, not updating or restoring content on a computer. The exception is iTunes Store purchased content.
    iTunes Store: Transferring purchases from your iOS device or iPod to a computer - http://support.apple.com/kb/HT1848 - only media purchased from iTunes Store
    For transferring other items from an i-device to a computer you will have to use third party commercial software. Examples (check the web for others; this is not an exhaustive listing, nor do I have any idea if they are any good):
    - Senuti - http://www.fadingred.com/senuti/
    - Phoneview - http://www.ecamm.com/mac/phoneview/
    - MusicRescue - http://www.kennettnet.co.uk/products/musicrescue/
    - Sharepod (free) - http://download.cnet.com/SharePod/3000-2141_4-10794489.html?tag=mncol;2 - Windows
    - Snowfox/iMedia - http://www.mac-videoconverter.com/imedia-transfer-mac.html - Mac & PC
    - iexplorer (free) - http://www.macroplant.com/iexplorer/ - Mac&PC
    - Yamipod (free) - http://www.yamipod.com/main/modules/downloads/ - PC, Linux, Mac [Still updated for use on newer devices? No edits to site since 2010.]
    - 2010 Post by Zevoneer: iPod media recovery options - https://discussions.apple.com/message/11624224 - this is an older post and many of the links are also for old posts, so bear this in mind when reading them.
    Syncing to a "New" Computer or replacing a "crashed" Hard Drive - https://discussions.apple.com/docs/DOC-3141 - dates from 2008 and some outdated information now.
    Copying Content from your iPod to your Computer - The Definitive Guide - http://www.ilounge.com/index.php/articles/comments/copying-music-from-ipod-to-co mputer/ - Information about use in disk mode pertains only to older model iPods.
    Get Your Music Off of Your iPod - http://howto.wired.com/wiki/Get_Your_Music_Off_of_Your_iPod - I am not sure but this may only work with some models and not newer Touch, iPhone, or iPad.
    Additional information here https://discussions.apple.com/message/18324797

  • How to delete the specified line in file?

    How to delete the specified line in file? In case of deleting a specified line in a file, how to do?
    Line 1
    Line 2
    Line 3
    Line 4
    Line 5
    The case is a file including the above content. Now I wanna to delete the "Line 3" and how to realize the action in Java?

    An alternative solution can be :
    import java.io.LineNumberReader;
    import java.io.IOException;
    import java.io.File;
    import java.io.FileReader;
    import java.io.BufferedWriter;
    import java.io.FileWriter;
    import java.io.PrintWriter;
    public class LineDeleter {
    public static void main(String args[]){
    try {
    //suppose you want to delete line 3
         int lineToBeDeleted = 3;
         File f = new File("line.txt");
         long fileSize = f.length();
    //Wrap the FileReader with a LineNumberReader. It will help you
    //identify the lines.
    LineNumberReader lnr = new LineNumberReader( new FileReader(f));
    //Wrap the FileWriter object with BufferedWriter object. Create it with the buffersize
    //equal to the file size.
         BufferedWriter bw = new BufferedWriter(new FileWriter(new File("line1.txt")),(int)fileSize);
    //Wrap BufferedWriter object with PrintWriter so that it allows you
    //to print line by line
    PrintWriter pw = new PrintWriter(bw);
         String s=null;
         while ( (s=lnr.readLine())!=null ){
              System.out.println(s);
              int lineNumber = lnr.getLineNumber();
    //match the line number
              if(! (lineNumber==lineToBeDeleted)){
                   pw.println(s);
              pw.flush();
              lnr.close();
              pw.close();
         catch(Exception e){System.out.println(e);}
    If you want you can rename the line1.txt to the original file name.
    I hope this helps.Good luck!!!!!!

  • When I delete com.apple.audio.SystemSettings.plist my audio/sound problems are solved. However when the file is replaced with another file, the sound is crappy and the quality is reduced. Can you please help me?

    When I delete com.apple.audio.SystemSettings.plist my audio/sound problems are solved. However when the file is replaced with another file, the sound is crappy and the quality is reduced. Can anyone please help me?
    Sincerely,
    Eric

    Run this when you have the problem and post the results here.
    EtreCheck
    This will tell us what is loaded

  • How to write single line text file

    Hi, I need to write a single line text file using oracle forms 10g that's usually quite long 8million+ characters, I looked into utl_file but came accross the single line limit, is there any way to do this either to the client pc or to the server
    Thanks

    I tried using put_line but i get a ORA-29285: file write error´I´m guessing this is because of the amount of data to be written on a single line

  • I downloaded CS6 Red Plug-In and added to Package Contents, replaced the current files with the new without backing up, now my RED footage thumbnails and color-correction don't WORK! How do I get my old importerRed file back!!?? HELP!

    I downloaded CS6 Red Plug-In and added to Package Contents, replaced the current files with the new without backing up, now my RED footage thumbnails and color-correction don't WORK! How do I get my old importerRed file back!!?? HELP!

    Try asking in the Premiere Pro  forum seems to be an Adobe Lab for Premiere Pro

Maybe you are looking for

  • How can i open a link in new window (shift + Mouse Click) while not switching to the new window

    I want to open a new window (shift + Mouse Click) while not switching to the newly opened window. The focus should remain on the window from where i have opened the link.

  • How to populate table at run time

    Hi All, I have a requirement like , i have department table and i created view object for that and dragged into jsp page as a single selection choice. when i select department id in the drop down list a table should be populated with the details //--

  • WVC200 1.2.0 firmware - or is it?

    Hmm, perhaps I should have left well enough alone. I've had my WVC200 working fine for a while - it emails on motion detection, and saves pics via FTP. But I moved it and thought I should check the web for updates. I got to the UK Linksys page at: ht

  • My iMac has gotten very slow lately

    Hi! I have an iMac 21.5-inch, purchased August 2010.  OS X 10.8.5 Lately it is been running very slow.  I double-click on an image, and Preview takes 30 seconds to open it.  I have done some reading and ran the EtreCheck report.  I see there are some

  • Table Fields of PR, PO and GRN

    Hi,               I have to prepare specs for a report having Materials , Quantity, Purchase Requisition No, Po No and GRN for a Particular Project . can any body please give the tables and fields for the above said. Full points will be awarded.... R