I have been cleaning up my music library and now have a need to locate all sub-folders and folders that contain files other than mp3's. Does anyone have a script that does this or is there a Regex that could be used to locate folders that contain files other than mp3's?
As usual, I am a Euro short and a day late. If you still need to find folders with no mp3 files, here is a crude piece of VBScript that will do it.
Run it from the command line or with a button:
Put it in a file with vbs extension, I use "aretheremp3s.vbs", then run it as:
cscript .vbs
I ran it as:
cscript aretheremp3s.vbs E:\test
Output will go into a file named notfound.txt
All this can be easily changed. If you run into permission problems, even running as admin, you can uncomment the line on error resume next. That will allow it to continue, skipping the folders you don't have permission to access. It should get the folder you name on the command line and all subfolders.
'uncomment to avoid permission errors
'on error resume next
dim arg,f, fs, fc, f1, found, fsOut, notfoundtextfile, counter
'function to look for .mp3 file types
function getdirs(dirname)
'ignore recycle bin, doc and settings and Sys Vol Info
if((instr(1,dirname, "RECYCLE",1)=0)AND (instr(dirname,"Documents and Settings")=0)) then
if(instr(dirname, "System Volume Information")=0) then
counter=0
found=0
Set fs = CreateObject("Scripting.FileSystemObject")
Set fsOut = CreateObject("Scripting.FileSystemObject")
set notfoundtextfile=fsOut.GetFile("notfound.txt")
set txtstr=notfoundtextfile.OpenAsTextStream(8) 'append mode
Set f = fs.GetFolder(dirname)
Set fc = f.Files
if(fc.count>0) then
For Each f1 in fc
if(instr(f1, ".mp3"))>0 then 'found an mp3
if(counter=0) then
'uncomment next if you want to see found paths
'wscript.echo "found: "& f.path
counter=1 ' don't look for any more mp3s
found=1 ' found, don't log thie folder
end if
end if
next
if(found=0) then ' no mp3
'uncomment next line if you want to see them
'wscript.echo "not found: "&f.path
txtstr.WriteLine(f.path) 'write path to file
end if
else
'uncomment if you want to see them
'wscript.echo "not found: "&f.path
txtstr.WriteLine(f.path) 'write path to file
end if
found=0
txtstr.close 'close the output file
set fd=f.subfolders 'look for subfolders
if(fd.count>0) then
for each fname in fd
getdirs(fname) 'recurse if subfolders
next
end if
end if
end if
End function
set arg = Wscript.Arguments
'create a new notfound.txt file
Set fsOut = CreateObject("Scripting.FileSystemObject")
set outfile=fsOut.CreateTextFile("notfound.txt", true)
outfile.close
getdirs(arg(0)) 'call function to check folders
wscript.echo "end"