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

^!CopyFile is frustraiting me!

Expand Messages
  • Ian A. Chapman
    The ^!CopyFile command is driving me around the bend. I m sure there is just some very small syntax error in my code, but I can t find it. What I m trying to
    Message 1 of 5 , Jul 17, 2006
    • 0 Attachment
      The ^!CopyFile command is driving me around the bend. I'm sure there
      is just some very small syntax error in my code, but I can't find it.

      What I'm trying to do is randomly select 200 images from set of 1642.
      I want to copy those images to a different directory. Of course I
      want them to be 200 unique images, so I built in a way to prevent
      repeats (thus leading to less then the desired 200).

      The process I use is this:

      -Set my Copied counter to zero
      -Fill an array with the files in the source directory

      -Calculate a random number between 1 and the number of files in the
      source directory
      -Check and see if that file has been previously copied
      -If it has been previously copied - print a message & generate another
      random number

      -If it is a unique file - increment my counter
      -Copy the file to the destination directory
      -Print a message showing what was copied
      -Set the element of the array for the copied file to blank (my method
      of preventing duplicates)
      -test to see if I have copied enough files
      -If not loop back to the Generate a random number stage

      The text messages that print look like the process is working
      correctly, and the logic is right. Buttttt - and you knew there was a
      but - no files actually get copied.

      What am I doing wrong?

      [Code]
      ^!Set %CopiedCounter%=0
      ^!SetArray %Files%=^$GetFiles("D:\Rodeo 2006";*.jpg)$
      ^!ToolBar New Document
      ^!InsertText List is ^%Files0% files long ^p^p

      :StartCopyLoop
      ^!Set %File2Copy%=^$Calc(RND(^%Files0%);0)$
      ^!If ^%Files^%File2Copy%%<>"" Ok2Copy
      ^!InsertText **** ^%File2Copy% ^%Files^%File2Copy%% - File already
      copied get another^p
      ^!Goto StartCopyLoop
      :Ok2Copy
      ^!Inc CopiedCounter
      ^!CopyFile "^%Files^%File2Copy%%" "D:\Rodeo 2006 Random\"
      ^!InsertText ^%CopiedCounter%-^%File2Copy% Copied
      ^%Files^%File2Copy%% -
      ^$GetImgWidth(^%Files^%File2Copy%%)$x^$GetImgHeight(^%Files^%File2Copy%%)$
      ^p
      ^!Set %Files^%File2Copy%%=""
      ^!If ^%CopiedCounter% < 200 StartCopyLoop
      ;** Done **
      [/Code]

      I have tried the CopyFile command with several different variations
      ^!CopyFile "^%Files^%File2Copy%%" "D:\Rodeo 2006 Random\"
      ^!CopyFile "^%Files^%File2Copy%%" "D:\Rodeo 2006 Random\*.*"
      ^!CopyFile "^%Files^%File2Copy%%" "D:\Rodeo 2006 Random"
      ^!CopyFile "^%Files^%File2Copy%%" "D:\Rodeo 2006 Random\junk.jpg"
      ^!CopyFile "^%Files^%File2Copy%%" "D:\Rodeo 2006 Random\**unique file
      names for each file**"

      I'm sure it's simple and obvious, but What am I doing wrong?

      Ian
    • Gary Oliver
      ... ^$GetImgWidth(^%Files^%File2Copy%%)$x^$GetImgHeight(^%Files^%File2Copy%%)$ ... Your Copy syntax is perfect but you must have a space at the end of the copy
      Message 2 of 5 , Jul 18, 2006
      • 0 Attachment
        --- In ntb-clips@yahoogroups.com, "Ian A. Chapman"
        <chapmani_nospam@...> wrote:
        >
        > The ^!CopyFile command is driving me around the bend. I'm sure there
        > is just some very small syntax error in my code, but I can't find it.
        >
        > What I'm trying to do is randomly select 200 images from set of 1642.
        > I want to copy those images to a different directory. Of course I
        > want them to be 200 unique images, so I built in a way to prevent
        > repeats (thus leading to less then the desired 200).
        >
        > The process I use is this:
        >
        > -Set my Copied counter to zero
        > -Fill an array with the files in the source directory
        >
        > -Calculate a random number between 1 and the number of files in the
        > source directory
        > -Check and see if that file has been previously copied
        > -If it has been previously copied - print a message & generate another
        > random number
        >
        > -If it is a unique file - increment my counter
        > -Copy the file to the destination directory
        > -Print a message showing what was copied
        > -Set the element of the array for the copied file to blank (my method
        > of preventing duplicates)
        > -test to see if I have copied enough files
        > -If not loop back to the Generate a random number stage
        >
        > The text messages that print look like the process is working
        > correctly, and the logic is right. Buttttt - and you knew there was a
        > but - no files actually get copied.
        >
        > What am I doing wrong?
        >
        > [Code]
        > ^!Set %CopiedCounter%=0
        > ^!SetArray %Files%=^$GetFiles("D:\Rodeo 2006";*.jpg)$
        > ^!ToolBar New Document
        > ^!InsertText List is ^%Files0% files long ^p^p
        >
        > :StartCopyLoop
        > ^!Set %File2Copy%=^$Calc(RND(^%Files0%);0)$
        > ^!If ^%Files^%File2Copy%%<>"" Ok2Copy
        > ^!InsertText **** ^%File2Copy% ^%Files^%File2Copy%% - File already
        > copied get another^p
        > ^!Goto StartCopyLoop
        > :Ok2Copy
        > ^!Inc CopiedCounter
        > ^!CopyFile "^%Files^%File2Copy%%" "D:\Rodeo 2006 Random\"
        > ^!InsertText ^%CopiedCounter%-^%File2Copy% Copied
        > ^%Files^%File2Copy%% -
        >
        ^$GetImgWidth(^%Files^%File2Copy%%)$x^$GetImgHeight(^%Files^%File2Copy%%)$
        > ^p
        > ^!Set %Files^%File2Copy%%=""
        > ^!If ^%CopiedCounter% < 200 StartCopyLoop
        > ;** Done **
        > [/Code]
        >
        > I have tried the CopyFile command with several different variations
        > ^!CopyFile "^%Files^%File2Copy%%" "D:\Rodeo 2006 Random\"
        > ^!CopyFile "^%Files^%File2Copy%%" "D:\Rodeo 2006 Random\*.*"
        > ^!CopyFile "^%Files^%File2Copy%%" "D:\Rodeo 2006 Random"
        > ^!CopyFile "^%Files^%File2Copy%%" "D:\Rodeo 2006 Random\junk.jpg"
        > ^!CopyFile "^%Files^%File2Copy%%" "D:\Rodeo 2006 Random\**unique file
        > names for each file**"
        >
        > I'm sure it's simple and obvious, but What am I doing wrong?
        >
        > Ian
        >

        Your Copy syntax is perfect but you must have a space at the end of
        the copy line. You should never have spaces at the end of a clip line
        unless you need a space in the output. I tested this and it does not
        copy any files with a space at the end of the copy files line.
      • Ian A. Chapman
        ... Gary: Thank you! Thank you! A million Thank You s! You were perfectly correct! I never would have thought of a trailing space mucking up the works.
        Message 3 of 5 , Jul 18, 2006
        • 0 Attachment
          --- In ntb-clips@yahoogroups.com, "Gary Oliver" <OLIVERG@...> wrote:
          Gary:

          Thank you! Thank you! A million Thank You's!

          You were perfectly correct! I never would have thought of a trailing
          space mucking up the works. Heck I never even noticed there WAS a
          trailing space.

          Again, Merci!

          Ian


          >
          > Your Copy syntax is perfect but you must have a space at the end of
          > the copy line. You should never have spaces at the end of a clip line
          > unless you need a space in the output. I tested this and it does not
          > copy any files with a space at the end of the copy files line.
          >
        • Don Daugherty
          Lots of us have been bitten by that. Theres an option you can set to guard against it. I believe it s set via View/Options/Documents -- check Trim White
          Message 4 of 5 , Jul 19, 2006
          • 0 Attachment
            Lots of us have been bitten by that. Theres an option you can set to
            guard against it. I believe it's set via View/Options/Documents --
            check "Trim White Spaces".
            > I never would have thought of a trailing
            > space mucking up the works. Heck I never even noticed there WAS a
            > trailing space.
          • loro
            ... It s also available from the menu if one doesn t want to have it on all the time. Modify | Lines |Trim Blanks Lotta
            Message 5 of 5 , Jul 19, 2006
            • 0 Attachment
              Don Daugherty wrote:
              > > I never would have thought of a trailing
              > > space mucking up the works. Heck I never even noticed there WAS a
              > > trailing space.
              >Lots of us have been bitten by that. Theres an option you can set to
              >guard against it. I believe it's set via View/Options/Documents --
              >check "Trim White Spaces".

              It's also available from the menu if one doesn't want to have it on all the
              time.
              Modify | Lines |Trim Blanks

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