vbscript - for each loop: how to step out of conditions -
i stuck @ creating loop testing filenames vbscript. precise, trying perform jump in for each
loop. loop should test files in folder , in cases should delete files.
but while running, deletes file , tries test deleted file against next condition. solution end check , jump next file not able find working solution.
for each file in folder.files if (filename = "foo.bar") log.writeline("found foo.bar -> delete!") fs.deletefile (folder & file.name), true 'exit end if if (isnumeric(firstposition)) if (isnumeric(secondposition)) log.writeline("2 numbers seen -> alright!") else log.writeline("filename corrupt!") fs.copyfile file, errorfolder, true fs.deletefile file, true 'exit end if end if
use else
follows:
for each file in folder.files if (filename = "foo.bar") log.writeline("found foo.bar -> delete!") fs.deletefile (folder & file.name), true 'exit else if (isnumeric(firstposition)) if (isnumeric(secondposition)) log.writeline("2 numbers seen -> alright!") else log.writeline("filename corrupt!") fs.copyfile file, errorfolder, true fs.deletefile file, true 'exit end if else end if end if next
or elseif
follows
for each file in folder.files if (filename = "foo.bar") log.writeline("found foo.bar -> delete!") fs.deletefile (folder & file.name), true 'exit elseif (isnumeric(firstposition)) if (isnumeric(secondposition)) log.writeline("2 numbers seen -> alright!") else log.writeline("filename corrupt!") fs.copyfile file, errorfolder, true fs.deletefile file, true 'exit end if else end if next
there no goto
-like statement in vbscript; there structured control mechanisms only. read vbscript user's guide , vbscript language reference
Comments
Post a Comment