noone
Wed Mar 12 11:50:01 CDT 2008
Il giorno Sun, 9 Mar 2008 00:44:14 +0530, "Raghu" <te.raghu@gmail.com> ha scritto:
>I'm searching for a vbscript which would help me in displaying the folder
>details. eg. i want the folder view to be "Details" & with more columns like
>"Title, Artist, Album title" etc.
>can someone help.. thanks..
The first displays some info taken from the shell, the second uses mediaplayer to retrieve
title, artist, album title, bitrate, duration, ecc.
'<%
'************************************************
' File: Directory in XL.vbs (VBScript)
' Author: Giovanni Cenati
'
' Mostra in un foglio di excel l'elenco dei
' files della directory trascinata sopra l'icona
' dello script.
' Shows the directory list in an excel sheet.
'
http://digilander.libero.it/Cenati Codice vbscript
' liberamente utilizzabile citando il sito.
'************************************************
Dim oXL, oFile, objArgs,path,objShell,objShellFolder,i
dim Riga ' as the excel row where to show data
Title = "Directory in Excel - Cenati Giovanni"
Set objArgs = WScript.Arguments 'Vedo se ci sono degli argomenti passati allo script
if objargs.count=0 then 'altrimenti mostro come si usa il programma
msgbox "Trascinare una directory sul programma per averne l'elenco dei
files",vbinformation+vbokonly, Title
'msgbox "Drag a folder on the script icon to have the directory list in an excel
sheet.",vbinformation+vbokonly, Title
wscript.quit
end if
path = objArgs(0) 'questa variabile contiene il nome della directory da leggere
'Prepara l'accesso ai dati forniti dalla shell. Non funziona in Win NT4 sp6
'Creates needed objects - In WinNT Shell.app can't be instanced.
Set objShell=WScript.CreateObject("Shell.application")
Set objShellFolder=objshell.namespace(path)
'EXCEL: crea oggetto, lo rende visibile, aggiunge un foglio di lavoro.
'Creates excel sheet, make it visible, adds a workbook.
Set oXL = WScript.CreateObject("Excel.Application")
oXL.Visible = TRUE
oXL.WorkBooks.Add
'Intestazione delle colonne - Column headers
oXL.cells(1,1)= "Directory: "
oXL.cells(1,2)= path
for i=0 to 50 'Intestazioni delle colonne - Columns headers
oXL.cells(2, 1+i) = objShellFolder.getdetailsof(objShellFolder.items,i)
next
Riga=3
For Each oFile In objShellFolder.items 'recupero le informazioni sui files
'Chiede a Windows alcune altre informazioni sul file.
'Attenzione: a seconda delle versioni di windows, le colonne
'riportano dati diversi. Con winME ho il nome + 16 attributi.
'Warning: different OS report different data in different columns.
'this retrieves 50 infos + the filename (in Win ME).
for i=0 to 50
oXL.cells(Riga, 1+i) = objShellFolder.getdetailsof(oFile,i)
next
Riga=riga+1
Next
wscript.quit
'*** End ***
--------------------------------------------------------------------------------------------------------------------------------
'************************************************
' File: Lista file Mp3.vbs
' Autore: Giovanni Cenati Reventlov @ katamail . com
' Crea in excel una lista dei files Mp3 con alcuni dati aggiuntivi.
' Creates an excel file with a list of Mp3 files and some additional data.
' 2004/11/02
'************************************************
Set Player = createobject("wmplayer.ocx.7")
Set fso = CreateObject("Scripting.FileSystemObject")
set oXL = WScript.CreateObject("Excel.Application")
oXL.Visible = TRUE
oXL.WorkBooks.Add
'drive= inputbox ("Scan which drive?","List of Mp3 files - Cenati Giovanni","C:\")
drive= inputbox ("Nome del drive in cui cercare:","Lista files Mp3 - Cenati
Giovanni","C:\")
Mp3List= GetListOfMp3Files(drive)
songslist = Split(Mp3List, vbCrLf) 'Creates an array of the lines of the file
Mp3List=""
dim attr(10)
attr(1)= "Artist"
attr(2)= "Album"
attr(3)= "Author"
attr(4)= "Bitrate"
attr(5)= "CreationDate"
attr(6)= "Genre"
' Column Headers - Intestazioni delle colonne
oXL.cells(1,1)="File Name"
oXL.cells(1,2)="Name"
oXL.cells(1,3)="Durata(secondi)"
oXL.cells(1,4)="Durata(min,sec)"
for i= 1 to ubound(attr)
oXL.cells(1,4+i)=attr(i)
next
oXL.cells(1,11)="File size"
oXL.cells(1,12)="File date"
on error resume next 'for song names with accents àèìòù
for songnumber=0 to ubound(songslist)
row=songnumber+2
player.mediaCollection.add(songslist(songnumber))
player.url=songslist(songnumber)
oXL.cells(row,1)= songslist(songnumber)
oXL.cells(row,2)= player.currentmedia.name
oXL.cells(row,3)= player.currentmedia.duration
oXL.cells(row,4)= player.currentmedia.durationstring
for a=1 to 6
oXL.cells(row,4+a)=
player.currentMedia.getItemInfobyAtom(player.mediaCollection.getMediaAtom(attr(a)))
next
set f = fso.GetFile(songslist(songnumber))
oXL.cells(row,11)= f.size
oXL.cells(row,12)= f.DateCreated
wscript.sleep 60 'Altrimenti si blocca - Otherwise it hangs
next
oxl.cells(1,1).select
set oXl=nothing
msgbox "End of job - Cenati Giovanni" ,,"List of Mp3 Files"
function GetListOfMp3Files(drive)
dim fso, tmp, wshshell, ofile, path
cmd = "dir "& trim(drive) & "*.mp3 /s/b " ' Comando DOS
Const tmpFolder=2
Set fso = CreateObject("Scripting.FileSystemObject")
' Chiede al sistema un nome di file temporaneo.
' Asks Windows a unique temporary file name
tmp = fso.GetTempName
' Recupera il path del file temporaneo.
' Gets the complete path of the temp file
path = fso.GetSpecialFolder(tmpFolder)
tmp = path & "\" & tmp ' Questo è il pathname completo del file tmp.
' Crea un oggetto WshShell... Creates the needed wshell object
Set WshShell = CreateObject("WScript.Shell")
' Esegue il comando dos e redirige l'output sul file tmp
' Executes dos command and redirects the output on the tmp file
WSHShell.Run "%comspec% /c " & cmd & " >" & tmp, 0, True
' Legge il contenuto del file. Reads the content
Set oFile = fso.OpenTextFile(tmp)
GetListOfMp3Files = oFile.ReadAll
oFile.Close 'lo chiude - Closes the file
fso.DeleteFile tmp ' e lo cancella - and deletes it
end function
' *** End ***
--
Giovanni Cenati (Bergamo, Italy)
Write to user "Reventlov" and domain at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--