• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

test please delete

Collapse
This is a sticky topic.
X
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Originally posted by WTFH View Post
    A question for the geeks out there...
    I've got a text file that will be sent to me a couple of times a day. Each day the name of the file will be different (and not in a nice logical way).
    What I'd like to do is take the original file name and put it either at the start of the file or at the end of it, then rename the file to "INPUT.txt"

    Just wondering if anyone has done anything like that before and is bored.
    So you want to rename the file twice?
    EDIT: oh I misread. So does that mean you'll be overwriting the file or appending the new data each day?

    Comment


      Originally posted by ladymuck View Post
      So you want to rename the file twice?
      EDIT: oh I misread. So does that mean you'll be overwriting the file or appending the new data each day?
      Overwriting each time. File comes in today:
      AB-1234_5678.txt
      contents:
      blah blah blah1
      blah blah blah2
      blah blah blah3

      Change it to:
      INPUT.txt
      contents:
      AB-1234_5678
      blah blah blah1
      blah blah blah2
      blah blah blah3

      Once it's renamed, it then gets processed and deleted.
      …Maybe we ain’t that young anymore

      Comment


        Originally posted by WTFH View Post
        A question for the geeks out there...
        I've got a text file that will be sent to me a couple of times a day. Each day the name of the file will be different (and not in a nice logical way).
        What I'd like to do is take the original file name and put it either at the start of the file or at the end of it, then rename the file to "INPUT.txt"

        Just wondering if anyone has done anything like that before and is bored.
        Linux et al on the command line

        sed -i '$a foo.txt' foo.txt | mv foo.txt INPUT.txt

        That will append the original file name to the original file and rename it.
        "Being nice costs nothing and sometimes gets you extra bacon" - Pondlife.

        Comment


          Originally posted by WTFH View Post
          A question for the geeks out there...
          I've got a text file that will be sent to me a couple of times a day. Each day the name of the file will be different (and not in a nice logical way).
          What I'd like to do is take the original file name and put it either at the start of the file or at the end of it, then rename the file to "INPUT.txt"

          Just wondering if anyone has done anything like that before and is bored.
          Untested MS-DOS batch file; puts the filename at the start:

          Code:
          REM You might need another \ after %cd% as that's the working directory and I don't know how it ends
          REM First, echo the first argument to the command to the new file INPUT.TXT in the working directory
          ECHO %1 > "%cd%INPUT.txt"
          REM Apparently ECHO/ (N.B. NO space between "ECHO" and "/") will output a return character
          REM so the filename is on its own line
          ECHO/ >> "%cd%INPUT.txt"
          REM Then append the rest of the input file
          TYPE %1 >> "%cd%INPUT.txt"
          REM And delete the original. You *did* have a backup, didn't you? Maybe leave this line out
          REM and delete it manually...
          DEL "%cd%%1"
          Usage, assuming it's called THINGY.BAT: THINGY.BAT AB-1234_5678.txt

          Again: no testing done on this whatsoever, as MacOS still doesn't support MS-DOS batch file syntax and I don't seem to have any Windows VMs to hand
          Last edited by NickFitz; 12 October 2020, 19:48. Reason: Missed a second > on the second ECHO, needed to append rather than overwrite…

          Comment


            'ere, this isn't "Technical" you know.

            Tea: lamb's liver and bacon with onion gravy, very nice, stewed pears (sans custard), 0.91 pints of good Glengettie tea.

            Entertainment: "Elizabeth (1998)", inneresting enough what with the heads on pikes, burnings at the stake, et al.

            The dancing, not so much.
            When the fun stops, STOP.

            Comment


              Walk briskly walked, green ring closed

              And in a moment of genius that may well net me next year's Nobel Prize for Food, I modified the route to take in the award-winning chip shop, where I had placed an order online for collection before setting out. So that was tea sorted too: extremely nice fish and chips

              You have to choose a ten-minute time slot for collections, and I got there two minutes into mine and had to wait a couple of minutes for the chips, so it was all nice and fresh; it takes about eight or nine minutes to walk back home from there, and their wrapping kept it warm enough for that time

              Comment


                Originally posted by WTFH View Post
                A question for the geeks out there...
                I've got a text file that will be sent to me a couple of times a day. Each day the name of the file will be different (and not in a nice logical way).
                What I'd like to do is take the original file name and put it either at the start of the file or at the end of it, then rename the file to "INPUT.txt"

                Just wondering if anyone has done anything like that before and is bored.
                @Mods : This belongs in Technical...
                I was an IPSE Consultative Council Member, until the BoD abolished it. I am not an IPSE Member, since they have no longer have any relevance to me, as an IT Contractor. Read my lips...I recommend QDOS for ALL your Insurance requirements (Contact me for a referral code).

                Comment


                  Originally posted by DoctorStrangelove View Post
                  Entertainment: "Elizabeth (1998)", inneresting enough what with the heads on pikes, burnings at the stake, et al.

                  The dancing, not so much.
                  Sadly, with these things, the dancing is the price you have to pay for the pleasure of seeing hapless Catholics martyred

                  Comment


                    Originally posted by Scruff View Post
                    @Mods : This belongs in Technical...
                    Did you notice who the poster asking the question was?

                    Spot the issue?
                    merely at clientco for the entertainment

                    Comment


                      Originally posted by eek View Post
                      Did you notice who the poster asking the question was?

                      Spot the issue?
                      doh! Whoosh Parrot for eek...[emoji8]
                      I was an IPSE Consultative Council Member, until the BoD abolished it. I am not an IPSE Member, since they have no longer have any relevance to me, as an IT Contractor. Read my lips...I recommend QDOS for ALL your Insurance requirements (Contact me for a referral code).

                      Comment

                      Working...
                      X