Loading ...
Sorry, an error occurred while loading the content.
 

Batch compressor

Expand Messages
  • Ian Rastall
    There are no good HTML compressor programs, as I ve discovered. The best one just turns everything into one line, which NoteTab doesn t like. The best thing
    Message 1 of 9 , Nov 30, 2002
      There are no good HTML compressor programs, as I've discovered. The
      best one just turns everything into one line, which NoteTab doesn't
      like.

      The best thing I've found is (in NoteTab) Select All ; Modify -->
      Lines --> Compress ; Modify --> Lines --> Join Lines.

      That does the trick.

      What I don't know is how to automate this for an entire folder,
      including sub-folders. I've got a mirror of my massive HTML folder
      that I send files that are pre-processed to, and before I load them on
      to the server, I would like to compress them as well.

      Any ideas?

      Ian
      --

      http://www.aspipes.org/
      http://www.bookstacks.org/
    • Ian Rastall
      On Sat, 30 Nov 2002 04:53:33 -0500, Ian Rastall ... My best guess, right now, is to open all the files in the current folder, perform those actions on one
      Message 2 of 9 , Nov 30, 2002
        On Sat, 30 Nov 2002 04:53:33 -0500, Ian Rastall
        <idrastall@...> wrote:

        >The best thing I've found is (in NoteTab) Select All ; Modify -->
        >Lines --> Compress ; Modify --> Lines --> Join Lines.
        >
        >That does the trick.
        >
        >What I don't know is how to automate this for an entire folder,
        >including sub-folders.

        My best guess, right now, is to open all the files in the current
        folder, perform those actions on one file, move to the next open file,
        and do the same until it reaches the last one, then close and save all
        the files.

        I have no idea how to do this.

        But it's a start. I hope someone can help me with this.

        Ian
        --

        http://www.aspipes.org/
        http://www.bookstacks.org/
      • Peter Steeper
        Hi Ian, This clip will load all the file names of a specified type from a directory into an array. It then runs a loop until all the files are processed. You
        Message 3 of 9 , Nov 30, 2002
          Hi Ian,
          This clip will load all the file names of a specified type from a directory into an array. It then runs a loop until all the files are processed. You will need to set your default directory and specify the files types in the clip. See comments in clip.

          You'll need to insert your code for compressing the files or other processing that you want to do on each file.
          I always make a back up copy of the directory that I am processing until I'm confident that the clip works properly.

          I originally developed this type of clip to read a directory full of JPEGs and create photo gallery web pages automatically.

          Process Files
          ;Change the default directory in the next line.
          ^!Set %filepath%=^?[(T=D)Select Directory to Process=C:\Default directory path]
          ;Change the file type to process in the next line.
          ^!SetArray %Files%=^$GetFiles(^%filepath%;"*.jpg;*.jpeg";;NAME)$
          ^!If ^%Files0%<1 NoFiles
          ^!Set %numfiles%=^%Files0%
          ^!Set %I%=1

          :Loop

          ;Processing on files goes here
          ;Don't forget to put a save command in.

          ^!Inc %I%
          ^!If ^%I%>^%numfiles% End
          ^!Goto Loop

          :NoFiles
          ^!Info No .JPG or .JPEG photos were found in^P^%filepath%

          :End


          Peter Steeper
          Webmaster
          Photographic Guild of Nova Scotia
          www.photoguild.ns.ca

          Halifax, Nova Scotia
          Canada


          ----- Original Message -----
          From: Ian Rastall
          To: ntb-clips@yahoogroups.com
          Sent: Saturday, November 30, 2002 6:08 AM
          Subject: Re: [Clip] Batch compressor


          On Sat, 30 Nov 2002 04:53:33 -0500, Ian Rastall
          <idrastall@...> wrote:

          >The best thing I've found is (in NoteTab) Select All ; Modify -->
          >Lines --> Compress ; Modify --> Lines --> Join Lines.
          >
          >That does the trick.
          >
          >What I don't know is how to automate this for an entire folder,
          >including sub-folders.

          My best guess, right now, is to open all the files in the current
          folder, perform those actions on one file, move to the next open file,
          and do the same until it reaches the last one, then close and save all
          the files...



          [Non-text portions of this message have been removed]
        • Ian Rastall
          Hi Peter. Thanks for writing that clip for me. This is what I ve got ... ;Change the default directory in the next line. ^!Set %filepath%=^?[(T=D)Select
          Message 4 of 9 , Nov 30, 2002
            Hi Peter. Thanks for writing that clip for me. This is what I've got
            written:

            :Process Files
            ;Change the default directory in the next line.
            ^!Set %filepath%=^?[(T=D)Select Directory to Process=C:\Documents and
            Settings\Ian Rastall\My Documents\html2]
            ;Change the file type to process in the next line.
            ^!SetArray %Files%=^$GetFiles(^%filepath%;"*.html;*.txt";;NAME)$
            ^!If ^%Files0%<1 NoFiles
            ^!Set %numfiles%=^%Files0%
            ^!Set %I%=1

            :Loop

            ^!Open "*.html";"*.txt"
            ^!Menu Edit/Select All
            ^!Menu Modify/Lines/Compress
            ^!Menu Modify/Lines/Join Lines
            ^!Close Save
            ^!Document Next

            ^!Inc %I%
            ^!If ^%I%>^%numfiles% End
            ^!Goto Loop

            :NoFiles
            ^!Info No .html or .text files were found in^P^%filepath%

            :End

            It doesn't seem to work. It opens one file, does its voodoo on it, and
            then closes it. It seems to want a loop, but I see there's already one
            there, and it would have to be a conditional loop, and I'm not that
            far along yet.

            Can you think of how this could be changed?

            Ian
            --

            http://www.aspipes.org/
            http://www.bookstacks.org/
          • Alan C.
            Hello Ian, ... Just was missing the iterator so as to work each array element, in this case each file, work one file at a time until all are done. This will
            Message 5 of 9 , Nov 30, 2002
              Hello Ian,

              >closes it. It seems to want a loop, but I see there's already one
              >there, and it would have to be a conditional loop, and I'm not that
              >far along yet.

              Just was missing the iterator so as to work each array element, in this case each file, work one file at a time until all are done.

              This will get you further along. Perhaps it might complete what you need. Later, Alan.


              ^!If ^%Files0%<1 NoFiles
              ^!Set %numfiles%=^%Files0%
              ^!Set %I%=1

              ; changed from here to end change marker
              ^!SetScreenUpdate OFF
              :Loop

              ; Processing on each file goes here
              ; Don't forget to put a save command in.
              ; iterator code for array next line only
              ^!Open "^%filepath%^%Files^%I%%"
              ^!Menu Edit/Select All
              ^!Menu Modify/Lines/Compress
              ^!Menu Modify/Lines/Join Lines
              ^!Close Save
              ; End processing on each file
              ; end change marker

              ^!Inc %I%
              ^!If ^%I%>^%numfiles% End
              ^!Goto Loop

              :NoFiles
              ; end
            • Alan C.
              If it don t work, change one line. Change ^!Open ^%filepath%^%Files^%I%% make it instead so it is ^!Open ^%Files^%I%% -- Thanks. Alan.
              Message 6 of 9 , Nov 30, 2002
                If it don't work, change one line. Change

                ^!Open "^%filepath%^%Files^%I%%"

                make it instead so it is

                ^!Open "^%Files^%I%%"

                --
                Thanks. Alan.
              • Peter Steeper
                I think Alan has the answer for you. The array is %Files% but you have to specify which element in the array you want to process. ^%I% in ^%Files^%I%% will
                Message 7 of 9 , Nov 30, 2002
                  I think Alan has the answer for you. The array is %Files% but you have to specify which element in the array you want to process. ^%I% in ^%Files^%I%% will specify the element ie %Files1%, %Files2%, %Files3%, etc

                  -Peter
                  ----- Original Message -----
                  From: Alan C.
                  To: ntb-clips@yahoogroups.com
                  Sent: Saturday, November 30, 2002 8:26 PM
                  Subject: Re: [Clip] Batch compressor



                  If it don't work, change one line. Change

                  ^!Open "^%filepath%^%Files^%I%%"

                  make it instead so it is

                  ^!Open "^%Files^%I%%"

                  --
                  Thanks. Alan.


                  Yahoo! Groups Sponsor
                  ADVERTISEMENT




                  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


                  [Non-text portions of this message have been removed]
                • Ian Rastall
                  Just to make this interesting, I ve run into a further problem. I work with eBooks, and each chapter can be a few thousand lines long. When I try to compress
                  Message 8 of 9 , Nov 30, 2002
                    Just to make this interesting, I've run into a further problem.

                    I work with eBooks, and each chapter can be a few thousand lines long.
                    When I try to compress one of these, I get the error that the
                    paragraph is too long, and I end up with nothing, and have to replace
                    the file from the mirror (which thankfully I have).

                    It would be very helpful just to compress everything above the text,
                    which usually is around 200 lines long. The length is variable, but it
                    always ends in

                    <div class="text">

                    Now I'm *really* out of my territory. I assume the clip could search
                    for that string, and highlight everything up to it, but I wouldn't
                    know how to do that.

                    I'm in the process of revising the clip with the new code. If someone
                    were able to figure this new problem out, that would be great.

                    Ian
                    --

                    http://www.aspipes.org/
                    http://www.bookstacks.org/
                  • Alan C.
                    Hi Ian, ... ^!SetScreenUpdate OFF ... ^!Open ^%Files^%I%% ^!Jump DOC_START ^!Find IST ^!Jump SELECT_END ^!Set
                    Message 9 of 9 , Dec 1, 2002
                      Hi Ian,

                      >It would be very helpful just to compress everything above the text,
                      >which usually is around 200 lines long. The length is variable, but it
                      >always ends in
                      >
                      ><div class="text">


                      ^!SetScreenUpdate OFF
                      :Loop
                      ^!Open "^%Files^%I%%"
                      ^!Jump DOC_START
                      ^!Find "<div class="text">" IST
                      ^!Jump SELECT_END
                      ^!Set %SelEnd%=^$GetRow$:^$GetCol$
                      ^!Jump DOC_START
                      ^!SelectTo ^%SelEnd%
                      ; after 1st trial run, precede the next line with a semi colon
                      ^!Goto end
                      ; will then also need precede the next line with a semi colon
                      ^!Menu Edit/Select All
                      ^!Menu Modify/Lines/Compress
                      ; also in help checkout ^!Jump SELECT_START
                      ; Later, Alan
                    Your message has been successfully submitted and would be delivered to recipients shortly.