When you listen to a song, you will often delete some songs that you no longer listen to. This operation is generally completed in the player. After a long time, you will leave many lyrics that you no longer need. Although the lyrics do not occupy space, they are always uncomfortable and want to clear them. Do it.
Script File (clearlrc. JS)
Function
Handlefile
(Filename
)
{
Basename
=
FSO
.
Getbasename
(Filename
); // File name
Extname
=
FSO
.
Getextensionname
(Filename
); // Extension
If
(Extname
.
Tolowercase
()! =
"LRC"
) // Not a lyrics File
{
Return
;
}
// Find the corresponding MP3 file
Songfilename
=
Basename
+
". MP3"
;
Hasfile
=
FSO
.
Fileexists
(Dir
+
"//"
+
Songfilename
);
If
(!
Hasfile
) // No mp3 file, search for WMA
{
Songfilename
=
Basename
+
". Wma"
;
Hasfile
=
FSO
.
Fileexists
(Dir
+
"//"
+
Songfilename
);
If
(!
Hasfile
) // No WMA, delete the lyrics, and record logs
{
FSO
.
Deletefile
(Dir
+
"//"
+
Filename
);
Filedelnum
++;
Filedel
+ =
Filename
+
"/R/N"
;
}
}
}
Try
{
Dir
=
Wscript
.
Arguments
(0
);
}
Catch
(E
)
{
Dir
=
"."
;
}
DT
=
New
Date
();
Log
=
""
;
Filedelnum
=
0
;
Filedel
=
""
;
FSO
=
New
Activexobject
("Scripting. FileSystemObject"
);
Fld1
=
FSO
.
Getfolder
(Dir
);
FC
=
New
Enumerator
(Fld1
.
Files
);
For
(;!
FC
.
Atend
(); FC
.
Movenext
())
{
Handlefile
(FC
.
Item
().
Name
)
}
Log
=
"-----"
+
DT
.
Tolocalestring
() +
"Deleting files"
+
Filedelnum
+
"Items"
+
"-----/R/N"
;
Log
+ =
Filedel
;
Log
+ =
"/R/N"
;
// Record logs to files
Logfile
=
FSO
.
Opentextfile
(Dir
+
"//"
+
"Clearlrc. log"
,
8
,
True
);
Logfile
.
Write
(Log
);
Logfile
.
Close
();
Wscript
.
Echo
(Log
);
Now this file can clear the lyrics in its own directory. But it is not convenient enough. Add it to the right-click menu.
Create the following values in the registry:
Hkey_classes_root/directory/background/Shell/clearlrc default: Clear the lyrics (& B)
Hkey_classes_root/directory/background/Shell/clearlrc/command
Default Value: wscript E:/self-sufficiency/practical script/clearlrc. js
Hkey_classes_root/directory/Shell/clearlrc default: Clear the lyrics (& B)
Hkey_classes_root/directory/Shell/clearlrc/command
Default Value: wscript E:/self-sufficiency/practical script/clearlrc. js
OK.
PS: I am not responsible for the consequences of this script without strict testing.
PS again: win7 is really useful.