le but: renommer des fichiers .mp3 en nn - titre.mp3 en allant chercher nn et le titre dans les tags mp3.
ça marche bien sous XP sp2, ailleurs j'ai pas testé.
le code:
option explicit
const kTrack = 19
const kTitre = 10
const Test = 0 ' si 0, les changements sont apportés aux fichiers
dim output: output = ""
dim nl: nl = ""
sub print(s)
output = output & nl:output = output & s:nl = vbLF
end sub
sub EOP
wscript.echo output: output = "": nl = ""
end sub
dim objShell: Set objShell = CreateObject ("Shell.Application")
dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject")
dim objFolder
dim objFile
dim objArgs
dim NomDuDossier
dim NomDuFichier
dim NouveauNom
dim i
dim Dossier
dim TrackNum
dim Titre
Set objArgs = WScript.Arguments
For I = 0 to objArgs.Count - 1
Dossier = objArgs(I)
Set objFolder = objShell.Namespace(Dossier)
for each NomDuFichier in objFolder.Items
if ucase(mid(NomDuFichier, len(NomDuFichier)-3, 4)) = ".MP3" then
TrackNum = objFolder.GetDetailsOf(NomDuFichier, kTrack)
Titre = objFolder.GetDetailsOf(NomDuFichier, kTitre)
if len(TrackNum) < 2 then TrackNum = "0" & TrackNum
NouveauNom = TrackNum & " - " & Titre & ".mp3"
NouveauNom = Replace(Replace(NouveauNom, "\", "_"), "/", "-")
NouveauNom = Replace(Replace(NouveauNom, "<", "_"), ">", "_")
NouveauNom = Replace(Replace(NouveauNom, "?", "_"), "*", "_")
NouveauNom = Replace(Replace(NouveauNom, ":", "_"), "|", "_")
NouveauNom = Replace(NouveauNom, """", "''")
if Test = 1 then
print "ren """ & NomDuFichier & """ """ & NouveauNom & """"
else
set objFile = objFSO.GetFile(Dossier & "\" & NomDuFichier)
on error resume next
objFile.Name = NouveauNom
if err <> 0 then
err = 0
print NomDuFichier & " non changé :-("
else
print Dossier & "\" & NomDuFichier & " => " & NouveauNom
end if
on error goto 0
set objFile = nothing
end if
end if
next
EOP
Set objFolder = nothing
Next
mardi 27 novembre 2007
lundi 26 novembre 2007
Lister la musique
option explicit
dim objfolder, fout
dim s
Set objFolder = CreateObject("Shell.Application").Namespace("C:\MyMusic")
set fout = CreateObject("Scripting.FileSystemObject").CreateTextFile("C:\MyMusic.txt", true, true)
For Each s in objFolder.Items
if s <> "" and left(s, 1) <> "." and left(s, 1) <> "~" and s <> "My Playlists" then fout.WriteLine s
Next
fout.Close
set fout = Nothing
set objFolder = Nothing
wscript.Echo "Done!"
dim objfolder, fout
dim s
Set objFolder = CreateObject("Shell.Application").Namespace("C:\MyMusic")
set fout = CreateObject("Scripting.FileSystemObject").CreateTextFile("C:\MyMusic.txt", true, true)
For Each s in objFolder.Items
if s <> "" and left(s, 1) <> "." and left(s, 1) <> "~" and s <> "My Playlists" then fout.WriteLine s
Next
fout.Close
set fout = Nothing
set objFolder = Nothing
wscript.Echo "Done!"
Inscription à :
Articles (Atom)