try catch - tcl file rename and catching error if file exists -


I am a newbie, and in some files I picked from the list of files. I'm trying to add the Skip extension. If a file is already present in TCL fileName.skip, then I would like to capture the error, put my own message on the screen, and I will continue the next file. Here's the code I'm using:

  set I 0 foreach fileName [glob -nocomplain -type f [file $ basedir * .wav included]] {foreach line $ fileData {if {[ Regexp $ Line $ fileName] == 1} {If the file {{file name change $ fileName "$ fileName.skip"}}} {{"error file leaving file file does not already exist"} {continue} {Puts "$ fileName.", "Rename File" [file contains $ $ addir $ fileName] [File $ $ based on $ $ $ $ $ $ $ $ $ $ $ name] / Code>  

I have three files in my folder I am testing it on:

  test21.wav test21.wav.skip test22.wav   

This code executes at that point where it The name is given (or does not change the name of the file), but then it is printed on the screen:

  Error leaving the C: /xxx/test21.wav file already exists Skipping C: /xxx/test22.wav ... Error Name "C: /xxx/test22.wav": "$ fileName" $ ​​fileName.skip "" to change the file name.   when executing such file or any other Eshika not I out what it is about this error, sin ce script work I am using what I  hold  incorrectly? Or maybe this is something else ....  

Thank you in advance for your help!

You have given the file two names: once in the if command , In the second second block. You do not need the file rename command in the second block

Grab command works this way:

    < Li> execute block of code
  1. If the execution has failed, return 1. If success, return 0

    then, in its context:

      set I 0 foreach fileName [glob -nocomplain -type f [file join $ basedir * .wav]] {foreach line $ fileData {if {[regexp $ line $ fileName] == 1} {if {{Rename file $ fileName "$ fileName.skip"}}} {# "Error in skipping file $ name Skip Skip Ail already exists "} other {# renamed OK" to leave $ filename ... "incr i}}}    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -