Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3949922
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:33:02+00:00 2026-05-20T01:33:02+00:00

I wrote a small script to help re-organize my .mp3 collection. When I run

  • 0

I wrote a small script to help re-organize my .mp3 collection. When I run this script, sometimes it will process several thousand files till it would hit an error condition (normally a move of a file that had a special character in its name/path that I hadn’t counted for), but it would often exit the script with the text

Script execution time was exceeded on script “C:\DevSpace\mp3move.vbs”.
Script execution was terminated.

Im not sure why this is happening. In an effort to figure out where this occured I added several msgbox lines, and what I found is that a msgbox would popup, but then it would auto-close very quickly.

Here is the code – i appoligize for not getting the formatting correctly in the forum

'Takes all .MP3 files in the source dir, reads the Artist tag associated with that file
'Checks for a dir named after the artist in the destination dir
'If the folder artist/album does not exists, it will create it
'Then move the .mp3 file to the dest dir 
Dim oAppShell, oFSO, oFolder, oFolderItems

Dim strPath, i  

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) Then

  WScript.Echo "Folder " & strPath & " is inaccessble"

End If

Set oFolder = oAppShell.NameSpace(strPath)
Set oFolderItems = oFolder.Items()

sCreate = ""
sExist = ""
sMoved = ""
If (not oFolderItems is nothing) Then
  if oFolderItems.Count = 0 then 
    Wscript.echo "no files found in this folder: "  & strPath 
    WScript.Quit 
  end If

  If iDebug = 1 Then
    i = oFolderItems.count
    WScript.Echo i
  End If

For Each oItem in oFolderItems
    If iDebug = 1 Then
        i = i - 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" then 
        'get artist name
        sArtist = oFolder.GetDetailsOf(oItem, 20)

        If iDebug = 1 Then
            MsgBox oItem.name
            MsgBox sArtist
        End If

        'if 'The Beatles' change to 'Beatles, the'
        If InStr(LCase(sArtist),"the") = 1 Then
            sArtist = Mid(sArtist,5) & ", the"
        End If

        'remove \ from band name
        If InStr(sArtist,"\") > 0 Then
            sArtist = Replace(sAlbum,"\","")        
        End If        

        If InStr(sArtist,"/") > 0 Then
            sArtist = Replace(sAlbum,"/","")        
        End If        

        If iDebug = 1 Then
            MsgBox sArtist
        End If

        'if folder does not exist create
        'MsgBox sDestination & "\" & sArtist
        If oFSO.FolderExists(sDestination & "\" & sArtist) Then
            '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 from album name      
        If InStr(sAlbum,":") > 0 Then
            sAlbum = Replace(sAlbum,":","")     
        End if

        If InStr(sAlbum,"?") > 0 Then
            sAlbum = Replace(sAlbum,"?","")     
        End If      

        If InStr(sAlbum,"...") > 0 Then
            sAlbum = Replace(sAlbum,"...","")       
        End If

        If InStr(sAlbum,"/") > 0 Then
            sAlbum = Replace(sAlbum,"/","")     
        End If

        If InStr(sAlbum,"\") > 0 Then
            sAlbum = Replace(sAlbum,"\","")     
        End If

        'create dir artist/album
        If oFSO.FolderExists (sDestination & "\" & sArtist & "\" & sAlbum) Then
            '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 Then 
            MsgBox sSource & vbCrLf & sDest
        End If

        If oFSO.FileExists (sSource) Then
            oFSO.MoveFile sSource, sDest
            'sMoved = sMoved & sSource & " moved to " & sDest & vbcrlf
            'MsgBox smoved
        Else
            MsgBox sSource & " not moved"
        End If
    End If

    If iDebug = 1
        WScript.Sleep 1000
        WScript.Echo i
    End If
Next

If iDebug=1 
    WScript.Echo i
End if
'MsgBox sCreate

'MsgBox sExist

'MsgBox sMoved

End If
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:33:03+00:00Added an answer on May 20, 2026 at 1:33 am

    The problem existed with my input files. Some of the .mp3 files I was using to test with had non-ascii characters in the tags, and that caused the program to freeze

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started playing with Clojure, and I wrote a small script to help
I wrote a small PHP application several months ago that uses the WordPress XMLRPC
I have several small open-source projects that I wrote. All my attempts to find
I wrote a small script that provided a URL (For example: code.google.com/ajax/123/1235/214) Would tell
I wrote a little in page script to relocate a small box containing the
I wrote a small shell script based on an example I found here: https://bbs.archlinux.org/viewtopic.php?id=36305
I wrote a small script for work and when developing it everything was fine
I have this small PHP script: <?php session_start(); $var = array(); $var['key'] = 'Var
I'm trying to write a small script to change the current directory to my
I wrote a small PHP application that I'd like to distribute. I'm looking for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.