vbscript - Script timesout in the middle of execution -


i wrote small script re-organize .mp3 collection. when run script, process several thousand files till hit error condition (normally move of file had special character in name/path hadn't counted for), exit script text

script execution time exceeded on script "c:\devspace\mp3move.vbs". script execution terminated.

im not sure why happening. in effort figure out occured added several msgbox lines, , found msgbox popup, auto-close quickly.

here code - appoligize not getting formatting correctly in forum

'takes .mp3 files in source dir, reads artist tag associated file 'checks dir named after artist in destination dir 'if folder artist/album not exists, create 'then move .mp3 file dest dir  dim oappshell, ofso, ofolder, ofolderitems  dim strpath,    dim sinfo  idebug=0  sinfo = "item description"  strpath = "k:\_preprocess" sdestination = "k:\music"   set oappshell = createobject("shell.application") set ofso = createobject("scripting.filesystemobject")  if not ofso.folderexists(strpath)    wscript.echo "folder " & strpath & " inaccessble"  end if  set ofolder = oappshell.namespace(strpath) set ofolderitems = ofolder.items()  screate = "" sexist = "" smoved = "" if (not ofolderitems nothing)   if ofolderitems.count = 0      wscript.echo "no files found in folder: "  & strpath      wscript.quit    end if    if idebug = 1     = ofolderitems.count     wscript.echo   end if  each oitem in ofolderitems     if idebug = 1         = - 1     end if      if oitem.type = "mp3 audio file (mp3)" or oitem.type = "mp3 format sound (.mp3)"_     or oitem.type = "windows media audio file" or oitem.type = "mp3 format sound"          'get artist name         sartist = ofolder.getdetailsof(oitem, 20)          if idebug = 1             msgbox oitem.name             msgbox sartist         end if          'if 'the beatles' change 'beatles, the'         if instr(lcase(sartist),"the") = 1             sartist = mid(sartist,5) & ", the"         end if          'remove \ band name         if instr(sartist,"\") > 0             sartist = replace(salbum,"\","")                 end if                  if instr(sartist,"/") > 0             sartist = replace(salbum,"/","")                 end if                  if idebug = 1             msgbox sartist         end if          'if folder not exist create         'msgbox sdestination & "\" & sartist         if ofso.folderexists(sdestination & "\" & sartist)             'msgbox "exist"             sexist = sexist & sdestination & "\" & sartist & " exists" & vbcrlf         else             'msgbox "create " & sdestination & "\" & sartist             rtn = ofso.createfolder(sdestination & "\" & sartist)             screate = screate & sdestination & "\" & sartist & " created" & vbcrlf         end if                        'get album name         salbum = ofolder.getdetailsof(oitem, 14)          'remove special characters album name               if instr(salbum,":") > 0             salbum = replace(salbum,":","")              end if          if instr(salbum,"?") > 0             salbum = replace(salbum,"?","")              end if                if instr(salbum,"...") > 0             salbum = replace(salbum,"...","")                end if          if instr(salbum,"/") > 0             salbum = replace(salbum,"/","")              end if          if instr(salbum,"\") > 0             salbum = replace(salbum,"\","")              end if          'create dir artist/album         if ofso.folderexists (sdestination & "\" & sartist & "\" & salbum)             'sexist = sexist & sdestination & "\" & sartist & salbum & " exists" & vbcrlf         else             'msgbox sdestination & "\" & sartist & "\" & salbum             rtn = ofso.createfolder (sdestination & "\" & sartist & "\" & salbum)             'screate = screate & sdestination & "\" & sartist & " created" & vbcrlf         end if          'move file         ssource = strpath & "\" & oitem.name & ".mp3"         sdest = sdestination & "\" & sartist & "\" & salbum & "\"          if idebug=1              msgbox ssource & vbcrlf & sdest         end if          if ofso.fileexists (ssource)             ofso.movefile ssource, sdest             'smoved = smoved & ssource & " moved " & sdest & vbcrlf             'msgbox smoved         else             msgbox ssource & " not moved"         end if     end if      if idebug = 1         wscript.sleep 1000         wscript.echo     end if next  if idebug=1      wscript.echo end if 'msgbox screate  'msgbox sexist  'msgbox smoved  end if 

you should set wscript.timeout property higher value.

see example here


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -