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

Re: [Clip] clip to save all index.html as index.htm

Expand Messages
  • hsavage
    ... directories for ... it to ... Mike, I m a regex novice, as most of us are, so, a clip language solution to this is more easily understood. If I understand
    Message 1 of 12 , Nov 2, 2006
    • 0 Attachment
      Mike Breiding wrote:
      > Greetings,
      > Would it be possible to write a clip which would check all
      directories for
      > the presence of index.html and then make a copy of this file and have
      it to
      > file named index.htm?
      >
      > Thanks,
      > -Mike

      Mike,

      I'm a regex novice, as most of us are, so, a clip language solution to
      this is more easily understood.

      If I understand correctly you want to rename all occurrences of
      'INDEX.HTML' to 'INDEX.HTM', is that right?

      With the following clip you can do that and it gives you the option of
      choosing which drive to do to do the renaming on. Give it a try if you
      want.

      *******************
      H="Change INDEX.HTML > HTM"
      ;_ Modified-Updated~Created_20061102
      ;_ hrs ø hsavage·pobox·com_02:39:31p
      ^!ClearVariables
      ^!SetWizardTitle "Select 'Drive ' to Scan for INDEX.HTML Files"
      ^!Set %drv%=^?{(T=D)Drive to Scan for INDEX.HTML=C:\}
      ^!SetListDelimiter ^%nL%
      ; this was a test line to check another drive, 'E:\'
      ;^!SetArray %ndxhtml%="^$StrTrim(^$GetDosOutput(dir/-p/a/b/on/s
      ^%drv%Twinky.HTML)$)$"
      ^!SetArray %ndxhtml%="^$StrTrim(^$GetDosOutput(dir/-p/a/b/on/s
      ^%drv%INDEX.HTML)$)$"
      ^!Set %pfnl%=0
      :FILELIST
      ^!Inc %pfnl%
      ^!RenameFile "^%ndxhtml^%pfnl%%" "^$StrDeleteRight("^%ndxhtml^%pfnl%%";1)$"
      ; creates a variable to display changed names in ^!Info [L] box.
      ;^!Append %changed%="^$StrDeleteRight("^%ndxhtml^%pfnl%%";1)$"^%nL%
      ^!If ^%pfnl% < ^%ndxhtml0% FILELIST
      ;^!Info [L]^%changed%
      ************************

      ºvº
      2006.11.02
      -Newspaper HeadLine...
      "British Union Finds Dwarfs in Short Supply"
      hrs ø hsavage@...
    • Mike Breiding
      ... Greetings, Actually, I want to copy all files named index.html to files named index.htm, not just rename them. In other words the subdirs with only
      Message 2 of 12 , Nov 2, 2006
      • 0 Attachment
        At 04:39 PM 11/2/2006 , hsavage wrote:
        >Mike,
        >
        >I'm a regex novice, as most of us are, so, a clip language solution to
        >this is more easily understood.
        >
        >If I understand correctly you want to rename all occurrences of
        >'INDEX.HTML' to 'INDEX.HTM', is that right?

        Greetings,

        Actually, I want to copy all files named index.html to files named
        index.htm, not just rename them.

        In other words the subdirs with only index.html would then contain an
        additional file, a copy of index.html which would be named index.htm.

        So it is both a copy and rename task.

        Thanks!

        -Mike




        [Non-text portions of this message have been removed]
      • hsavage
        ... Mike, Very easily done with a change to the ^!RenameFile line. Changed, tested, clip below! *************** H= Copy INDEX.HTML HTM ;_
        Message 3 of 12 , Nov 2, 2006
        • 0 Attachment
          Mike Breiding wrote:
          > At 04:39 PM 11/2/2006 , hsavage wrote:
          >> Mike,
          >>
          >> If I understand correctly you want to rename all occurrences of
          >> 'INDEX.HTML' to 'INDEX.HTM', is that right?
          >
          > Greetings,
          >
          > Actually, I want to copy all files named index.html to files named
          > index.htm, not just rename them.
          >
          > In other words the subdirs with only index.html would then contain an
          > additional file, a copy of index.html which would be named index.htm.
          >
          > So it is both a copy and rename task.
          >
          > Thanks!
          >
          > -Mike

          Mike,

          Very easily done with a change to the ^!RenameFile line. Changed,
          tested, clip below!

          ***************
          H="Copy INDEX.HTML > HTM"
          ;_ Modified-Updated~Created_20061102
          ;_ hrs ø hsavage·pobox·com_02:39:31p
          ^!ClearVariables
          ^!SetWizardTitle "Select 'Drive ' to Scan for INDEX.HTML Files"
          ^!Set %drv%=^?{(T=D)Drive to Scan for INDEX.HTML=C:\}
          ^!SetListDelimiter ^%nL%
          ; this was a test line to check another drive, 'E:\'
          ;^!SetArray %ndxhtml%="^$StrTrim(^$GetDosOutput(dir/-p/a/b/on/s
          ^%drv%Twinky.HTML)$)$"
          ^!SetArray %ndxhtml%="^$StrTrim(^$GetDosOutput(dir/-p/a/b/on/s
          ^%drv%INDEX.HTML)$)$"
          ^!Set %pfnl%=0
          ; ·····
          ^!SetDebug 1
          ; -----
          :FILELIST
          ^!Inc %pfnl%
          ^!CopyFile "^%ndxhtml^%pfnl%%" "^$StrDeleteRight("^%ndxhtml^%pfnl%%";1)$"
          ;^!RenameFile "^%ndxhtml^%pfnl%%" "^$StrDeleteRight("^%ndxhtml^%pfnl%%";1)$"
          ; creating a variable to display changed names in ^!Info [L] box.
          ;^!Append %changed%="^$StrDeleteRight("^%ndxhtml^%pfnl%%";1)$"^%nL%
          ^!If ^%pfnl% < ^%ndxhtml0% FILELIST
          ;^!Info [L]^%changed%
          ********************

          ºvº
          2006.11.02
          -Newspaper HeadLine...
          "British Union Finds Dwarfs in Short Supply"
          hrs ø hsavage@...
        • Mike Breiding
          ... ============= Works great! Thanks, -Mike [Non-text portions of this message have been removed]
          Message 4 of 12 , Nov 3, 2006
          • 0 Attachment
            At 06:29 PM 11/2/2006 , you wrote:
            ><trim>
            > > So it is both a copy and rename task.
            > > Thanks!> -Mike
            >
            >Mike,
            >Very easily done with a change to the ^!RenameFile line. Changed,
            >tested, clip below!
            >***************
            >H="Copy INDEX.HTML > HTM"
            >;_ Modified-Updated~Created_20061102
            >;_ hrs ø hsavage·pobox·com_02:39:31p
            >^!ClearVariables
            >^!SetWizardTitle "Select 'Drive ' to Scan for INDEX.HTML Files"
            >^!Set %drv%=^?{(T=D)Drive to Scan for INDEX.HTML=C:\}
            >^!SetListDelimiter ^%nL%
            >; this was a test line to check another drive, 'E:\'
            >;^!SetArray %ndxhtml%="^$StrTrim(^$GetDosOutput(dir/-p/a/b/on/s
            >^%drv%Twinky.HTML)$)$"
            >^!SetArray %ndxhtml%="^$StrTrim(^$GetDosOutput(dir/-p/a/b/on/s
            >^%drv%INDEX.HTML)$)$"
            >^!Set %pfnl%=0
            >; ·····
            >^!SetDebug 1
            >; -----
            >:FILELIST
            >^!Inc %pfnl%
            >^!CopyFile "^%ndxhtml^%pfnl%%" "^$StrDeleteRight("^%ndxhtml^%pfnl%%";1)$"
            >;^!RenameFile "^%ndxhtml^%pfnl%%" "^$StrDeleteRight("^%ndxhtml^%pfnl%%";1)$"
            >; creating a variable to display changed names in ^!Info [L] box.
            >;^!Append %changed%="^$StrDeleteRight("^%ndxhtml^%pfnl%%";1)$"^%nL%
            >^!If ^%pfnl% < ^%ndxhtml0% FILELIST
            >;^!Info [L]^%changed%
            >********************
            >ºvº
            >2006.11.02
            >-Newspaper HeadLine...
            >"British Union Finds Dwarfs in Short Supply"
            >hrs ø
            ><mailto:hsavage%40pobox.com>hsavage@pobox.<mailto:hsavage%40pobox.com>com

            =============
            Works great!

            Thanks,
            -Mike





            [Non-text portions of this message have been removed]
          • abairheart
            ... index.htm? ... Yes, DOS is the more efficient way to go, but you do not need to loop to get the job done, if you use XCOPY. Let DOS/Windows do the hard
            Message 5 of 12 , Nov 5, 2006
            • 0 Attachment
              --- In ntb-clips@yahoogroups.com, Veli-Pekka Tätilä <vtatila@...> wrote:
              >
              > Mike Breiding wrote:
              > > <snip> check all directories for index.html and make a copy to
              index.htm?

              > The native Windows/DOS way is potentially much more interesting as it
              > doesn't need Perl. You gotta run this on the command-line and put the
              > command in a single line:
              >
              > for /f "usebackq delims=" %a in (`dir /s /b index.html`) do copy "%a"
              > "%~dpna.htm"
              >


              Yes, DOS is the more efficient way to go, but you do not need to loop
              to get the job done, if you use XCOPY. Let DOS/Windows do the hard
              stuff. See the sample clip below.

              Here is an excerpt from XCOPY help:

              XCOPY source [destination] /S /C /Q [/L] [/H] /Y

              source Specifies the file(s) to copy.
              destination Specifies the location and/or name of new files.
              /S Copies directories and subdirectories except empty ones.
              /C Continues copying even if errors occur.
              /Q Does not display file names while copying.
              /F Displays full source and destination file names while
              copying.
              /L Displays files that would be copied.
              /H Copies hidden and system files also.
              /Y Suppresses prompting to confirm you want to overwrite


              The ONE thing you must do is set the path in your clip before you
              execute the XCOPY command, otherwise, the destination files will not
              go to the correct folder.

              Use something like

              H="html to html plus htm"
              ^!Set %path%=site's root path (wizard or hard-code)
              ^!ChDr ^%path%
              ^!Dos "^%path%index.html" *.htm /S /C /Q /H /Y

              That's it. It will do the entire tree of files, if you want to TEST
              the result first, replace the /Q switch with the /L switch. Files will
              not actually get copied, but displayed in the commandline window.

              One more trick:

              append the DOS command with a "&pause" to keep the commandline window
              OPEN, when testing, so you can inspect the result at leisure.

              ^!Dos "^%path%index.html" *.htm /S /C /L /H /Y&pause


              Abair
            Your message has been successfully submitted and would be delivered to recipients shortly.