Author: FiberOPtics -- mirc.fiberoptics@gmail.com
Usage:
1)
$fileinfo(filepath, properties [,separator])[.raw]
Will retrieve information about a file. The possible properties are listed further below.
2)
$findfileinfo( initialize, properties [, seperator])[.raw]
$findfileinfo()
$findfileinfo(quit)
Findfileinfo is specifically designed to be used when you want to retrieve properties about files from a large collection. For example if you want to retrieve audio properties from your audio folder, which may contain hundreds or thousands of file, then $findfileinfo will be better suited than fileinfo.
You first initialize findfileinfo by specifying as first parameter the word "initialize" and as second parameters the properties that you will retrieve from each file in the collection. Once you are done with retrieving the info, you can use "initialize" again to set new properties or you can quit by specifying the keyword "quit". Let's make an example:
$findfileinfo(initialize, Artist Title Genre Duration Bitrate Audiosamplerate)
!.echo -q $findfile(d:\my audio\,*,0,aline @info $findfileinfo($1-))
$findfileinfo(quit)
3)
/listtags
This alias will list all available properties that you can use on your system. These properties will be in the language of your OS, but you must always use the English properties that you see right under this.
Properties:
Audio/video: Title Artist Author AlbumTitle Year TrackNumber Genre Duration BitRate Audiosamplesize Audiosamplerate Channels Protected Copyright EpisodeName Comments
Pictures: CameraModel DatePictureTaken Dimensions
Executables: ProgramDescription Company Description FileVersion ProductName ProductVersio
Misc: Attributes Status Owner Subject Category Pages
Common: Name Size Type DateModified DateCreated DateAccessed
Purpose: Returns up to 37 characteristics of any file. For example version information of .exe files, audio information of .wma/.mp3 files, etc. This uses Windows to retrieve the properties, which are the same when you right click a column label in Windows Explorer to specify which attributes from a file you want to see as default.
Info:
alias fileinfo {
var %e = return $+($chr(3),$color(info),$,fileinfo:), %result
if ($version < 5.91) %e This snippet requires atleast mIRC 5.91
if ($istok($OS,95 98,32)) %e This snippet can only work on Windows ME or higher.
if (!$isid) %e This function can only be used as an identifier.
if (!$isfile($1)) %e File doesn't exist: $1-
if (* !iswm $2) %e You didn't specify a property to retrieve.
var %id = $ticks $+ $r(1111,9999), %mss = mss $+ %id, %t, %n = $crlf
var %file = $1, %list, %sep = $iif($len($3)," $+ $3",vblf)
var %props = $&
Name Size Type DateModified DateCreated DateAccessed Attributes Status Owner Author Title $&
Subject Category Pages Comments Copyright Artist AlbumTitle Year TrackNumber Genre Duration $&
BitRate Protected CameraModel DatePictureTaken Dimensions . . EpisodeName ProgramDescription . $&
Audiosamplesize Audiosamplerate Channels Company Description FileVersion ProductName ProductVersion
tokenize 32 $2
while ($0) {
if ($findtok(%props,$1,1,32)) %list = $addtok(%list,$+(",$1,:,$calc($ifmatch - 1),"),44)
tokenize 32 $2-
}
if (!%list) %e You didn't supply any valid properties.
.comopen %mss MSScriptControl.ScriptControl
if ($comerr) %e Error opening ScriptControl object.
%t = $com(%mss,language,4,bstr*,vbscript)
%t = $&
list = array( %list ) %n $&
set shell = createobject("shell.application") %n $&
set folder = shell.namespace(" $+ $nofile(%file) $+ ") %n $&
set item = folder.parsename(" $+ $nopath(%file) $+ ") %n $&
for each index in list %n $&
tmp = split(index,":") %n $&
prop = folder.getdetailsof(item,tmp(1)) %n $&
if len(prop) = 0 then : prop = 0 : end if %n $&
$iif($prop != raw,prop = tmp(0) & ": " & prop) %n $&
result = result & prop & %sep %n $&
next %n $&
result = left(result,len(result) - len( %sep ))
if ($com(%mss,executestatement,1,bstr*,%t)) && ($com(%mss,eval,3,bstr*,result)) %result = $com(%mss).result
else %e Error executing VBScript to retrieve fileinfo.
:error
if ($com(%mss)) .comclose %mss
return %result
}
; Use this alias if you want to use fileinfo on a large collection of files at once
; when used with $findfile on an entire folder and subfolders
alias findfileinfo {
var %t, %obj = findfileinfo
if ($1 == initialize) {
var %e = return $+($chr(3),$color(info),$,findfileinfo:)
if ($version < 5.91) %e This snippet requires atleast mIRC 5.91
if ($istok($OS,95 98,32)) %e This snippet can only work on Windows ME or higher.
if ($2 == $null) %e you must specify properties to retrieve.
if ($com(%obj)) .comclose %obj
.comopen %obj MSScriptControl.ScriptControl
var %sep = $iif($len($3)," $+ $3",vblf), %n = $crlf, %list
var %props = $&
Name Size Type DateModified DateCreated DateAccessed Attributes Status Owner Author Title $&
Subject Category Pages Comments Copyright Artist AlbumTitle Year TrackNumber Genre Duration $&
BitRate Protected CameraModel DatePictureTaken Dimensions . . EpisodeName ProgramDescription . $&
Audiosamplesize Audiosamplerate Channels Company Description FileVersion ProductName ProductVersion
tokenize 32 $2
while ($0) {
if ($findtok(%props,$1,1,32)) %list = $addtok(%list,$+(",$1,:,$calc($ifmatch - 1),"),44)
tokenize 32 $2-
}
if (!%list) %e you didn't specify any valid properties.
%t = $com(%obj,language,4,bstr*,vbscript)
%t = $&
Function FindFileInfo(dir,file) %n $&
list = array( %list ) %n $&
set shell = createobject("shell.application") %n $&
set folder = shell.namespace(dir) %n $&
set item = folder.parsename(file) %n $&
for each index in list %n $&
tmp = split(index,":") %n $&
prop = folder.getdetailsof(item,tmp(1)) %n $&
if len(prop) = 0 then : prop = 0 : end if %n $&
$iif($prop != raw,prop = tmp(0) & ": " & prop) %n $&
%obj = %obj & prop & %sep %n $&
next %n $&
%obj = left( %obj ,len( %obj ) - len( %sep )) %n $&
End Function
%t = $com(%obj,addcode,1,bstr*,%t)
return $iif(%t == 1,$true,$false)
}
elseif ($1 == quit) {
if ($com(%obj)) .comclose %obj
}
else {
if ($com(%obj)) {
%t = $+(FindFileInfo,$chr(40),",$nofile($1),",$chr(44),",$nopath($1),") )
%t = $com(%obj,eval,3,bstr*,%t)
return $com(%obj).result
}
}
}
alias listtags {
if ($version < 6.14) return
var %t = $ticks, %i = 0
var %objShell = a $+ %t, %objFolder = b $+ %t
.comopen %objShell shell.application
if (!$comerr) {
%t = $com(%objShell,namespace,1,bstr,$mircdir,dispatch* %objFolder)
if ($com(%objFolder)) {
echo -ac info * Listing available properties on your system...
while (%i < 40) {
%t = $com(%objFolder,getdetailsof,1,bstr*,null,uint,%i)
echo -a Index %i - $com(%objFolder).result
inc %i
}
.comclose %objFolder
}
.comclose %objShell
}
}