I need a script that copies the filename into the file

I need a script that copies the filename into 4th column of each line in the text doc file.
I have over 2000 different file names each containing 6 columns and ~50-100 rows.
I can do this manually using this script:
awk '{print $1"\t"$2"t\"$3"\t <name> \t"$6}'
But I would like an automation command or script. Is there any command that I can use instead of <name> that will copy the filename into the column?
Thanks
Monica

Oops, I forgot the redirect to a file. It's not a good idea to edit files in place. A script could fail and you're left with at least one file ruined. It's better to create new files then delete the old files.
for file in *; do
    while read col1 col2 col3 col4 col5 col6; do              
        printf "%s\t%s\t%s\t%s\t%s\n" $col1 $col2 $col3 $file $col6
    done < $file > n$file
done
You could narrow the files listed such as
for file in *.tsv
and redirect the new files to another directory. Such as
done < $file > /absolute/path/to/directory/$file

Similar Messages

  • Is there a possibility to print the filename into the picture?

    Is there a possibility to print the filenames into the picture or into the slideshow? When presenting photos to clients over Apple TV there must be a way to find the image name for ordering.
    Any ideas, I did not find anything!

    Unsure about slide show in Ap, but when printing llok for this dialogue box, it prints any metadata;
    You just need to select the more options bottom left.
    Tony

  • I need a script that will find the computer a user last logged into.

    I am still learning scripting, I need a script that will allow me to pull in usernames from a csv file. Find what computer they last logged into and output that to an csv file.
    I have looked all over and can't find exactly what I need.
     I found the following script but I need  to add the resuitsize unlimited but can not figure out where to put it we have a large environment. Also I need to be able to grab username from a csv file. Any assistance you can provide is appreciated.
    ##  Find out what computers a user is logged into on your domain by running the script
    ##  and entering in the requested logon id for the user.
    ##  This script requires the free Quest ActiveRoles Management Shell for Active Directory
    ##  snapin  http://www.quest.com/powershell/activeroles-server.aspx
    Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue
    $ErrorActionPreference = "SilentlyContinue"
    # Retrieve Username to search for, error checks to make sure the username
    # is not blank and that it exists in Active Directory
    Function Get-Username {
    $Global:Username = Read-Host "Enter username you want to search for"
    if ($Username -eq $null){
    Write-Host "Username cannot be blank, please re-enter username!!!!!"
    Get-Username}
    $UserCheck = Get-QADUser -SamAccountName $Username
    if ($UserCheck -eq $null){
    Write-Host "Invalid username, please verify this is the logon id for the account"
    Get-Username}
    get-username resultsize unlimited
    $computers = Get-QADComputer | where {$_.accountisdisabled -eq $false}
    foreach ($comp in $computers)
    $Computer = $comp.Name
    $ping = new-object System.Net.NetworkInformation.Ping
      $Reply = $null
      $Reply = $ping.send($Computer)
      if($Reply.status -like 'Success'){
    #Get explorer.exe processes
    $proc = gwmi win32_process -computer $Computer -Filter "Name = 'explorer.exe'"
    #Search collection of processes for username
    ForEach ($p in $proc) {
    $temp = ($p.GetOwner()).User
    if ($temp -eq $Username){
    write-host "$Username is logged on $Computer"

    If you are querying by user "resultset size" will be of no use.
    You also have functions that are never used and the body code doe snot look for users.
    Here is what you scrip looks like if printed well.  It is just a jumble of pasted together and unrelated items.
    ## Find out what computers a user is logged into on your domain by running the script
    ## and entering in the requested logon id for the user.
    ## This script requires the free Quest ActiveRoles Management Shell for Active Directory
    ## snapin http://www.quest.com/powershell/activeroles-server.aspx
    Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue
    $ErrorActionPreference = "SilentlyContinue"
    # Retrieve Username to search for, error checks to make sure the username
    # is not blank and that it exists in Active Directory
    Function Get-Username {
    $Global:Username = Read-Host "Enter username you want to search for"
    if ($Username -eq $null) {
    Write-Host "Username cannot be blank, please re-enter username!!!!!"
    Get-Username
    $UserCheck = Get-QADUser -SamAccountName $Username
    if ($UserCheck -eq $null) {
    Write-Host "Invalid username, please verify this is the logon id for the account"
    Get-Username
    get-username resultsize unlimited
    $computers = Get-QADComputer | where { $_.accountisdisabled -eq $false }
    foreach ($comp in $computers) {
    $Computer = $comp.Name
    $ping = new-object System.Net.NetworkInformation.Ping
    $Reply = $null
    $Reply = $ping.send($Computer)
    if ($Reply.status -like 'Success') {
    #Get explorer.exe processes
    $proc = gwmi win32_process -computer $Computer -Filter "Name = 'explorer.exe'"
    #Search collection of processes for username
    ForEach ($p in $proc) {
    $temp = ($p.GetOwner()).User
    if ($temp -eq $Username) {
    write-host "$Username is logged on $Computer"
    I suggest finding the original code then use the learning link at the top of this page to help you understand how it works in Powershell.
    ¯\_(ツ)_/¯

  • I need to start and stop logging based on a digital input event(or analog if necessary), log data for several seconds prior to the event, and have the data file close at the end of event and increment the filename for the next logging event.

    I don't know if this can be done with VI Logger or need to use Labview V7.1.

    After browsing through the VI Logger User Manual, it looks like the triggering that you are hoping to accomplish is possible. However, incrementing the filename for the next logging event is not going to be possible. VI Logger does exactly what its name tells - logs data. I don't think the automation that you are hoping to accomplish is possible.
    For help with setting up your application, if you do choose to stay with VI Logger, make sure to chek out the Getting Started with VI Logger Manual.
    Best of luck.
    Jared A

  • I need a script that can delete duplicate songs within iTunesMedia but not shown on iTunes GUI

    I copied entire music in itunes library A and paste it in itunes library B. I subsequently experimented with import playlist and import .XML files of itunes library A to itunes library B. I notice songs in music folder have been duplicated i.e. the gigabyte of music folder greated than gigabyte shown on itunes GUI.
    Wow, I never knew importing .XML file (through import playlist) will import the songs, the metadata, the artwork and the entire playlist which i never created in the first place (I dont know what else had been imported).
    Anyway, the songs are not duplicated on the iTunes GUI. They are duplicated within iTunesMedia\Music... folders. Can someone provide me a Script to delete these approx. 100GB duplicates. The DeDuper Script I have can only delete duplicate songs displayed on iTunes GUI.
    Thanks for your help as usual.

    The script is only intended to work on things that iTunes would treat as "Exact Duplicates" and it only works on files that are connected to the iTunes library. Before starting all files in your media folders should be added to the iTunes library.
    In the context of the earlier thread, type 1 or logical duplicates are multiple entries to the same file and type 2 or physical duplicates are multiple copies of the same file. Type 2 dupes will have identical tag information (at least they will unless you edit one of them) and the same file size so will thus display as "Exact Duplicates" if present.
    The script avoids the more complex problem of trying to detect and selectively remove what I called type 3 duplicates, that is alternate recordings or rips of the same tune, principally because that is a much harder problem to automate, but also because "best track to keep" from a set of potential candiates will be a subjective matter.
    The current version of the DeDuper script is 1.0.1.2 dated 2nd December 2011. I've just downloaded and run it on a test library. I had 35 tracks that I first duplicated by copying the Music folder into Automatically Add to iTunes. I then renamed Music as Music1, selected each file in turn so that iTunes would "know" the files were missing, renamed the folder back to Music and then dragged & dropped the folder into the library. This created a library of 140 tracks, 35 originals, 35 physical dupes and 70 logical dupes . The script ran as designed and reduced the library back down to 35 tracks with the 35 physical dupes being sent to the recycle bin.
    tt2

  • I need to know that how we should analyse the bdoc error

    Hi Experts,
    I am monitoring the BODCs in the crm system, through the transaction smw01 ( both in & out).
    there are a alots of erros in the queue.most of the erros are related to BUPA_MAIN & the queue are from r/3 (R3AD_CUSTOME)
    I need to know that how we should analyse the bdoc error. should i need to reprocess those error.
    PLease add experts point on this.
    Thanks & Regards
    Prajith P
    Moderation: Locked. Rule number one: Try to find the answer first. [See rules of engagement.|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
    Edited by: Joaquin Fornas on Oct 25, 2011 8:45 AM

    Install 7. Don't bother with applying drivers and such, just reboot again from DVD and install again, it will see the existing system and this time activation will be possible.
    Vista is mess, takes longer etc. Hope you have SP1 version of 7. And for Vista, only SP2+ are even supported now, by MS.

  • Hello,  Is there a script that I can change all the colors of a layer in to 1 PMS color, unite every object and than give it an offset of -0,2 mm ?

    Hello,
    Is there a script that I can change all the colors of a layer in to 1 PMS color, unite every object and than give it an offset of -0,2 mm ?

    the offset has to be semi-automatic, apply an Offset Path Effect (by hand), create a Graphic Style out of it (by hand), then the script can apply this graphic style to objects.

  • Oracle script that was used to confirm the web services working????

    I am having major problems with the top 2 web servers and top 3 app servers, which would be the cluster facing our external customers. This is how our our web services are deployed. I used an oracle script that was used to confirm the web services worked when I installed this working with the oracle consultant taken from metalink. I simply edited it for our web services.
    Can’t deploy web services. Using a script. 2 work on 2 of the machines. Doesn't always work on third machines. Third web service doesn't work on any of the machines.
    Please help, Thank you

    Please can you provide more information, its really not much to work with when u just my web server is not working. any log files ...error messages ?

  • I need a script that only allows numerics to be keyed in

    I need a script that only allows numerics to be keyed in.

    Thank you so very much.  You kindness is appreciated.
    K Wiley
    On Thu, Oct 17, 2013 at 3:46 AM, Gilad D (try67)

  • Processing the filename in the payload

    Hi,
    I am getting the filename in the payload, I want to read that file.
    How do I achieve this..
    Regards,
    Varun

    Hi,
    For Example if we want to get the Input file name & Directory Details into Target message.
    Ex:
    I/P File name is :::::231004.xml  Ftp Serve Path : //xideveloper/Test_XI/PO
    O/P File name can be :::Any thing
    Input File :  231004.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_TEST_AGCO xmlns:ns0="http://tafe.test.com">
       <Header>
          <NAME>giri</NAME>
       </Header>
    </ns0:MT_TEST_AGCO>
    Output File : Out.xml
    Here in this output we are able to get the Filename & Directory Info in the FileName_1 Field.
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MT_target xmlns:ns0="http://test.com">
    - <Header>
      <Name_1>giri</Name_1>
      <File_Name_1>231004.xml //xideveloper/Test_XI/PO/</File_Name_1>
      </Header>
      </ns0:MT_target>
    You should capture the Source File name & Directory Info into Target Message.
    1)     Write One UDF & Map Like Constant(u201Cu201D)---UDF----FileName_1
    2)            In Advanced mode check the check box Set Adapter-Specific Attributes
    3)     Check the ASMA Parameters in Sender Adapter Alone
    4)             No need to check the check box ASMA in the receiver side
    UDF Code:
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    //for getting filename
    DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    //for getting directory
    DynamicConfigurationKey key2 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");
    /similarly for getting filetype, filesize you need to specify in the above code instead of filename or directory/
    String FileName = conf.get(key1);
    String Directory = conf.get(key2);
    String Cat = FileName+ " "+Directory;
    //return FileName;
    //return Directory;
    return Cat;
    Regards
    Seshagiri

  • Retaining the FileName in the Receiver FTP adapter

    Hi experts,
    I have a situation here, were i need to retain the FileName in the message header in the receiver FTP adapter.
    I have tried using variable subtitution but seems the FileName is not supported in variable substitution.
    Please help
    Thanks

    Hello,
    if you need file name to be retained in the receiver adapter from the sender side. then u can do that by dynamic configuration using adapter specific message attributes, check this blog for details-
    /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
    if you dont have a mapping in your interface to use dynamic configuration, then you can do it via adapter module also- have a look here, /people/sap.user72/blog/2005/07/15/copy-a-file-with-same-filename-using-xi
    regards,
    francis

  • Grabbing the filename of the document a dynamic stamp is being placed into.

    I need to get the filename of the "parent" document a stamp is being placed into to put into one of the stamps textfields. This was what I was hoping would work inside of stamps textfield custom calculation:
    event.value = app.activeDocs[0].documentFileName;
    Thats a no go. For some reason activeDocs is always empty, despite the fact I have 3 pdfs open. Does anyone have any ideas on why this is not working? Have a better idea to do the same thing?
    Thanks for your help.

    Thank you! Works great.
    And for those looking for the quick answer in the future:
    event.value = event.source.source.documentFileName;

  • My iPhone 4s is stuck on a black screen that shows a USB cable connecting to iTunes. The phone will not turn on and the iTunes logo as I described only shows up when I plug the phone into the charger or my computer. I have tried the reset in restore mode

    My iPhone 4s is stuck on a black screen that shows a USB cable connecting to iTunes. The phone will not turn on and the iTunes logo as I described only shows up when I plug the phone into the charger or my computer. I have tried the reset in restore mode as well as the DFU? mode and it still will not work. I have the latest version of iTunes on my Mac. My error code was 2002. I also tried it on my laptop (windows 8.1) and none of the above worked. My error code on my laptop was 02. The phone is through Verizon and it has absolutely no damage. It was working fine up until this and I have been trying to fix it for 2 days. Please help! I am unsure of what version the phone was currently running on before this because I have another iphone that's my primary phone and have not used this one in about a month. I do not believe it was updated to IOS 7.

    Your iPhone is in recoverty mode at the moment so to possibly get it back up and running you would need to do a restore as you have been trying. Follow the steps in the article below for the specific error messages you have been receiving. If after following all steps the issue remains book an appointment at a local Apple Retail Store to have the iPhone evaluated.
    Resolve specific iTunes update and restore errors

  • How do I create a 1d array that takes a single calculation and insert the result into the first row and then the next calculation the next time the loop passes that point and puts the results in thsecond row and so on until the loop is exited.

    The attached file is work inprogress, with some dummy data sp that I can test it out without having to connect to equipment.
    The second tab is the one that I am having the problem with. the output array from the replace element appears to be starting at the index position of 1 rather than 0 but that is ok it is still show that the new data is placed in incrementing element locations. However the main array that I am trying to build that is suppose to take each new calculation and place it in the next index(row) does not ap
    pear to be working or at least I am not getting any indication on the inidcator.
    Basically what I am attempting to do is is gather some pulses from adevice for a minute, place the results for a calculation, so that it displays then do the same again the next minute, but put these result in the next row and so on until the specifiied time has expired and the loop exits. I need to have all results displayed and keep building the array(display until, the end of the test)Eventually I will have to include a min max section that displays the min and max values calculated, but that should be easy with the min max function.Actually I thought this should have been easy but, I gues I can not see the forest through the trees. Can any one help to slear this up for me.
    Attachments:
    regulation_tester_7_loops.vi ‏244 KB

    I didn't really have time to dig in and understand your program in depth,
    but I have a few tips for you that might things a bit easier:
    - You use local variables excessively which really complicates things. Try
    not to use them and it will make your life easier.
    - If you flowchart the design (very similar to a dataflow diagram, keep in
    mind!) you want to gather data, calculate a value from that data, store the
    calculation in an array, and loop while the time is in a certain range. So
    theres really not much need for a sequence as long as you get rid of the
    local variables (sequences also complicate things)
    - You loop again if timepassed+1 is still less than some constant. Rather
    than messing with locals it seems so much easier to use a shiftregister (if
    absolutely necessary) or in this case base it upon the number of iterations
    of the loop. In this case it looks like "time passed" is the same thing as
    the number of loop iterations, but I didn't check closely. There's an i
    terminal in your whileloop to read for the number of iterations.
    - After having simplified your design by eliminating unnecessary sequence
    and local variables, you should be able to draw out the labview diagram.
    Don't try to use the "insert into array" vis since theres no need. Each
    iteration of your loop calculates a number which goes into the next position
    of the array right? Pass your result outside the loop, and enable indexing
    on the terminal so Labview automatically generates the array for you. If
    your calculation is a function of previous data, then use a shift register
    to keep previous values around.
    I wish you luck. Post again if you have any questions. Without a more
    detailed understanding of your task at hand it's kind of hard to post actual
    code suggestions for you.
    -joey
    "nelsons" wrote in message
    news:[email protected]...
    > how do I create a 1d array that takes a single calculation and insert
    > the result into the first row and then the next calculation the next
    > time the loop passes that point and puts the results in thsecond row
    > and so on until the loop is exited.
    >
    > The attached file is work inprogress, with some dummy data sp that I
    > can test it out without having to connect to equipment.
    > The second tab is the one that I am having the problem with. the
    > output array from the replace element appears to be starting at the
    > index position of 1 rather than 0 but that is ok it is still show that
    > the new data is placed in incrementing element locations. However the
    > main array that I am trying to build that is suppose to take each new
    > calculation and place it in the next index(row) does not appear to be
    > working or at least I am not getting any indication on the inidcator.
    >
    > Basically what I am attempting to do is is gather some pulses from
    > adevice for a minute, place the results for a calculation, so that it
    > displays then do the same again the next minute, but put these result
    > in the next row and so on until the specifiied time has expired and
    > the loop exits. I need to have all results displayed and keep building
    > the array(display until, the end of the test)Eventually I will have to
    > include a min max section that displays the min and max values
    > calculated, but that should be easy with the min max function.Actually
    > I thought this should have been easy but, I gues I can not see the
    > forest through the trees. Can any one help to slear this up for me.

  • Issue with the new COPA field added into the BBSEG Structure

    Hello All,
    I have an issue with the new COPA field added into the BBSEG Structure.
    I think its added becuase of test Operationa Conern Created by somebody.
    Can you please let me know how to remove that structure from BBSEG Structure.
    Thanks
    vsr

    Hi Monohar & Ankur,
      Thanks for your answers..
      main issue is suddenly new field called RKE_COPA_KOSTL has  been added to the BBESG Structure..
      Because of this RFBIBL00 Upload is not working. I heard that  this new fields will come by generating Operating Concerns by Transaction KEA0.I found an operating concern which was created as a test in developemt system..
      But I am not sure how to delete that operating concern.Even i am not sure if we delete the Operating Concern ..is it going to delete that field in BBESG Structure or not??
    Please advise me..
    Thanks
    sathi

Maybe you are looking for

  • Why does Adobe Reader X1 show text as weird characters in online pdf?

    Updated to Reader X1 recently. When I open a PDF on my desktop, it displays normally. When I look at a PDF online, it displays a series of random characters (like fl fl   fl) replacing the text. I want to upload a screenshot of an example but get an

  • Attaching Video by Email

    Hello Everybody, what is the max video size I can share via email. I noticed that even with short videos (15sec) I cannot attach it since they are too big. Is there any specific size/time I can share ? Or is there any resizing app to help me in shari

  • Can´t believe how Applecare works!!!

    I send them my ipod because it has a sad icon when it gets started.I told them that it has been for two weeks in my car without being used or charged and that after trying to charge it again this icon appeared. Now the problem is that my ipod had the

  • BI Activities in Service Pack Upgrade

    Hi, We are upgrading all the systems to the next service pack. Presently BI is on Netweaver Stack 12 and application stack 14. Basis is planning to upgrade the Netweaver stack to 17 and application stack to 19. As part of this upgrade project they wo

  • Has anyone experienced Netflix not loading recently?

    I have windows vista and have been having problems getting Netflix to load anything when I click to Play on my Apple, this is recent within the last week. I can get it through my Blue ray but not thru Apple. Any suggestions?