ConsultingJoe Posted February 26, 2007 Share Posted February 26, 2007 (edited) $iTunesApp = ObjCreate("iTunes.Application") For $track in $iTunesApp.SelectedTracks If $track.Location = 0 Then $track.Delete;error here EndIf Next This script is supposed to simply delete tracks without locations. It is only giving me the problem at the "$track.delete" command. The documentation says I can do this though. Please help Thanks Edited February 26, 2007 by CyberZeroCool [center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center] Link to comment Share on other sites More sharing options...
ConsultingJoe Posted February 26, 2007 Author Share Posted February 26, 2007 (edited) I've tried this but it removed all the tracks, because of the "IF" $iTunesApp = ObjCreate("iTunes.Application") $iLibrary = $iTunesApp.LibraryPlaylist $allTracks = $iLibrary.Tracks $count = 0 $removed = 0 $total = $allTracks.count ProgressOn( "ITunes Clean Up", "Cleaning..." ) For $track in $allTracks $count = $count + 1 ProgressSet( ($count/$total)*100, $track.Location ) If $track.Location = 0 Then ProgressSet( ($count/$total)*100, "", $removed & " Tracks Removed" ) $track.Delete $removed = $removed + 1 EndIf Next ProgressSet( 100, "Complete" ) Sleep(1000) Edited February 26, 2007 by CyberZeroCool [center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center] Link to comment Share on other sites More sharing options...
ConsultingJoe Posted February 27, 2007 Author Share Posted February 27, 2007 Any help? [center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center] Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted February 27, 2007 Moderators Share Posted February 27, 2007 Here's something I threw together real quick. expandcollapse popup#include <IE.au3> _IEErrorHandlerRegister() $oiTunes = ObjCreate("iTunes.Application") $oMainLibrary = $oiTunes.LibraryPlaylist $oTracks = $oMainLibrary.Tracks $iDeletedTracks = _iTunesRemoveDeletedTracks($oTracks) If $iDeletedTracks Then If $iDeletedTracks == 1 Then MsgBox(0, "Cleanup", "Removed 1 dead track.") Else MsgBox(0, "Cleanup", "Removed " & $iDeletedTracks & " dead tracks.") EndIf Else MsgBox(0, "Cleanup", "No dead tracks were found.") EndIf Func _iTunesRemoveDeletedTracks($o_Tracks, $f_Log = 1) ; The ITTrackKindFile value will be use to check if a track is a physical file Local $ITTrackKindFile = 1, $iDeletedTracks = 0 If $f_Log Then $Log = FileOpen(@ScriptDir & "\DeletedTracks.txt", 1) For $oTrack In $o_Tracks If $oTrack.Kind <> $ITTrackKindFile Then ContinueLoop If $oTrack.Location <> "" Then ContinueLoop If $f_Log Then $sArtist = $oTrack.Artist $sSong = $oTrack.Name FileWriteLine($Log, $sArtist & " - " & $sSong) EndIf $oTrack.Delete () $iDeletedTracks += 1 Next Return $iDeletedTracks EndFunc ;==>_iTunesRemoveDeletedTracks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now