-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRefreshNonDead.js
More file actions
45 lines (42 loc) · 1.12 KB
/
Copy pathRefreshNonDead.js
File metadata and controls
45 lines (42 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
var iTunesApp = WScript.CreateObject("iTunes.Application");
var mainLibrary = iTunesApp.LibraryPlaylist;
var tracks = mainLibrary.Tracks;
var numTracks = tracks.Count;
var i;
var ITTrackKindFile = 1;
var deletedTracks = 0;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var deadTracks = fso.CreateTextFile("DeadTracks.txt", true);
for (i = 1; i <= numTracks; i++)
{
var currTrack = tracks.Item( i );
// is this a file track?
if ( ( currTrack != null ) &&
( currTrack.Kind == ITTrackKindFile ) )
{
// yes, does it have an empty location?
if ( ( currTrack.Location == "" ) ||
( ! fso.FileExists( currTrack.Location ) ) )
{
// write info about the track to a file
deadTracks.WriteLine( currTrack.Artist + "," + currTrack.Album + "," + currTrack.Name + "," + currTrack.Location );
deletedTracks++;
}
else
{
if ( fso.FileExists( currTrack.Location ) )
{
currTrack.UpdateInfoFromFile();
}
}
}
}
if (deletedTracks > 0)
{
WScript.Echo("Found " + deletedTracks + " dead track(s).");
}
else
{
WScript.Echo("No dead tracks were found.");
}
deadTracks.Close();