Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'iTunes does not see changes to the 'Automatically Add to iTunes' folder on a network location.
- 'This script can be run at regular intervals. There is no call to add a track to the library without conversion,
- 'But if you create a playlist with the contents of the folder, iTunes will import the files and move them to the library.
- 'The script then deletes the playlist created to trigger the import.
- 'Update folderPath = "\\nas\iTunes\iTunes Music\Automatically Add to iTunes" with the correct path for your import folder.
- ' Define the folder path as a variable
- Dim folderPath
- folderPath = "\\nas\iTunes\iTunes Music\Automatically Add to iTunes"
- ' Function to check if a folder contains files, excluding a specific subfolder
- Function ContainsFiles(folder, excludeFolderName)
- Dim subFolder, file
- ' Check files in the current folder
- For Each file In folder.Files
- ContainsFiles = True
- Exit Function
- Next
- ' Recursively check subfolders, except the excluded one
- For Each subFolder In folder.SubFolders
- If LCase(subFolder.Name) <> LCase(excludeFolderName) Then
- If ContainsFiles(subFolder, excludeFolderName) Then
- ContainsFiles = True
- Exit Function
- End If
- End If
- Next
- ContainsFiles = False
- End Function
- ' Check if the folder exists
- Dim objFSO, objFolder
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- If objFSO.FolderExists(folderPath) Then
- Set objFolder = objFSO.GetFolder(folderPath)
- Else
- WScript.Quit
- End If
- ' Check if the folder or its subfolders (excluding "not added") contain files
- If Not ContainsFiles(objFolder, "not added") Then
- ' If no files found
- WScript.Quit
- Else
- ' Add to iTunes
- Dim iTunesApp
- Set iTunesApp = WScript.CreateObject("iTunes.Application")
- Dim List
- Set List = iTunesApp.CreatePlaylist("zAutomatic")
- List.AddFile(folderPath)
- List.Delete()
- End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement