Attribute - 脚本函数
此脚本函数用于返回不同媒体文件的元标签的值作为文本。支持以下格式:MP3、WMA、WMV、PNG 和 JPG。如文件 filename 不存在,则它不是一种支持的文件格式或不包含一个称为 attributename 的元标签,将会返回 NULL 值。
语法:
Attribute(filename, attributename)
可以读取大多数元标签。本主题中的示例显示了可以为相应的支持文件类型读取的标签。
信息注释根据相关规范,您只能读取保存在文件中的元标签,例如 ID2v3(MP3 文件)或 EXIF(JPG 文件),而不能读取 Windows File Explorer 中的元信息。
参数:
参数
filename
|
如有必要,媒体文件名称包括路径作为文件夹数据连接。
示例: 'lib://Table Files/'
在传统脚本模式下,同时支持以下路径格式:
|
attributename
|
元标签的名称。 |
以下示例使用 GetFolderPath 函数查找指向媒体文件的路径。因为在旧模式下仅支持 GetFolderPath,当您在标准模式或 Qlik Sense SaaS 中使用该功能时,您需要将对 GetFolderPath 的引用替换为 lib:// 数据连接路径。
文件系统访问限制
示例 1: MP3 文件
此脚本读取文件夹 MyMusic 中所有可能的 MP3 元标签。
// Script to read MP3 meta tags for each vExt in 'mp3' for each vFoundFile in filelist( GetFolderPath('MyMusic') & '\*.'& vExt ) FileList: LOAD FileLongName, subfield(FileLongName,'\',-1) as FileShortName, num(FileSize(FileLongName),'# ### ### ###',',',' ') as FileSize, FileTime(FileLongName) as FileTime, // ID3v1.0 and ID3v1.1 tags Attribute(FileLongName, 'Title') as Title, Attribute(FileLongName, 'Artist') as Artist, Attribute(FileLongName, 'Album') as Album, Attribute(FileLongName, 'Year') as Year, Attribute(FileLongName, 'Comment') as Comment, Attribute(FileLongName, 'Track') as Track, Attribute(FileLongName, 'Genre') as Genre,
// ID3v2.3 tags Attribute(FileLongName, 'AENC') as AENC, // Audio encryption Attribute(FileLongName, 'APIC') as APIC, // Attached picture Attribute(FileLongName, 'COMM') as COMM, // Comments Attribute(FileLongName, 'COMR') as COMR, // Commercial frame Attribute(FileLongName, 'ENCR') as ENCR, // Encryption method registration Attribute(FileLongName, 'EQUA') as EQUA, // Equalization Attribute(FileLongName, 'ETCO') as ETCO, // Event timing codes Attribute(FileLongName, 'GEOB') as GEOB, // General encapsulated object Attribute(FileLongName, 'GRID') as GRID, // Group identification registration Attribute(FileLongName, 'IPLS') as IPLS, // Involved people list Attribute(FileLongName, 'LINK') as LINK, // Linked information Attribute(FileLongName, 'MCDI') as MCDI, // Music CD identifier Attribute(FileLongName, 'MLLT') as MLLT, // MPEG location lookup table Attribute(FileLongName, 'OWNE') as OWNE, // Ownership frame Attribute(FileLongName, 'PRIV') as PRIV, // Private frame Attribute(FileLongName, 'PCNT') as PCNT, // Play counter Attribute(FileLongName, 'POPM') as POPM, // Popularimeter
Attribute(FileLongName, 'POSS') as POSS, // Position synchronisation frame Attribute(FileLongName, 'RBUF') as RBUF, // Recommended buffer size Attribute(FileLongName, 'RVAD') as RVAD, // Relative volume adjustment Attribute(FileLongName, 'RVRB') as RVRB, // Reverb Attribute(FileLongName, 'SYLT') as SYLT, // Synchronized lyric/text Attribute(FileLongName, 'SYTC') as SYTC, // Synchronized tempo codes Attribute(FileLongName, 'TALB') as TALB, // Album/Movie/Show title Attribute(FileLongName, 'TBPM') as TBPM, // BPM (beats per minute) Attribute(FileLongName, 'TCOM') as TCOM, // Composer Attribute(FileLongName, 'TCON') as TCON, // Content type Attribute(FileLongName, 'TCOP') as TCOP, // Copyright message Attribute(FileLongName, 'TDAT') as TDAT, // Date Attribute(FileLongName, 'TDLY') as TDLY, // Playlist delay
Attribute(FileLongName, 'TENC') as TENC, // Encoded by Attribute(FileLongName, 'TEXT') as TEXT, // Lyricist/Text writer Attribute(FileLongName, 'TFLT') as TFLT, // File type Attribute(FileLongName, 'TIME') as TIME, // Time Attribute(FileLongName, 'TIT1') as TIT1, // Content group description Attribute(FileLongName, 'TIT2') as TIT2, // Title/songname/content description Attribute(FileLongName, 'TIT3') as TIT3, // Subtitle/Description refinement Attribute(FileLongName, 'TKEY') as TKEY, // Initial key Attribute(FileLongName, 'TLAN') as TLAN, // Language(s) Attribute(FileLongName, 'TLEN') as TLEN, // Length Attribute(FileLongName, 'TMED') as TMED, // Media type
Attribute(FileLongName, 'TOAL') as TOAL, // Original album/movie/show title Attribute(FileLongName, 'TOFN') as TOFN, // Original filename Attribute(FileLongName, 'TOLY') as TOLY, // Original lyricist(s)/text writer(s) Attribute(FileLongName, 'TOPE') as TOPE, // Original artist(s)/performer(s) Attribute(FileLongName, 'TORY') as TORY, // Original release year Attribute(FileLongName, 'TOWN') as TOWN, // File owner/licensee Attribute(FileLongName, 'TPE1') as TPE1, // Lead performer(s)/Soloist(s) Attribute(FileLongName, 'TPE2') as TPE2, // Band/orchestra/accompaniment
Attribute(FileLongName, 'TPE3') as TPE3, // Conductor/performer refinement Attribute(FileLongName, 'TPE4') as TPE4, // Interpreted, remixed, or otherwise modified by Attribute(FileLongName, 'TPOS') as TPOS, // Part of a set Attribute(FileLongName, 'TPUB') as TPUB, // Publisher Attribute(FileLongName, 'TRCK') as TRCK, // Track number/Position in set Attribute(FileLongName, 'TRDA') as TRDA, // Recording dates Attribute(FileLongName, 'TRSN') as TRSN, // Internet radio station name Attribute(FileLongName, 'TRSO') as TRSO, // Internet radio station owner
Attribute(FileLongName, 'TSIZ') as TSIZ, // Size Attribute(FileLongName, 'TSRC') as TSRC, // ISRC (international standard recording code) Attribute(FileLongName, 'TSSE') as TSSE, // Software/Hardware and settings used for encoding Attribute(FileLongName, 'TYER') as TYER, // Year Attribute(FileLongName, 'TXXX') as TXXX, // User defined text information frame Attribute(FileLongName, 'UFID') as UFID, // Unique file identifier Attribute(FileLongName, 'USER') as USER, // Terms of use Attribute(FileLongName, 'USLT') as USLT, // Unsychronized lyric/text transcription Attribute(FileLongName, 'WCOM') as WCOM, // Commercial information Attribute(FileLongName, 'WCOP') as WCOP, // Copyright/Legal information
Attribute(FileLongName, 'WOAF') as WOAF, // Official audio file webpage Attribute(FileLongName, 'WOAR') as WOAR, // Official artist/performer webpage Attribute(FileLongName, 'WOAS') as WOAS, // Official audio source webpage Attribute(FileLongName, 'WORS') as WORS, // Official internet radio station homepage Attribute(FileLongName, 'WPAY') as WPAY, // Payment Attribute(FileLongName, 'WPUB') as WPUB, // Publishers official webpage Attribute(FileLongName, 'WXXX') as WXXX; // User defined URL link frame LOAD @1:n as FileLongName Inline "$(vFoundFile)" (fix, no labels); Next vFoundFile Next vExt
示例 2: JPEG
此脚本从文件夹 MyPictures 中的 JPG 文件读取所有可能的 EXIF 元标签。
// Script to read Jpeg Exif meta tags for each vExt in 'jpg', 'jpeg', 'jpe', 'jfif', 'jif', 'jfi' for each vFoundFile in filelist( GetFolderPath('MyPictures') & '\*.'& vExt )
FileList: LOAD FileLongName, subfield(FileLongName,'\',-1) as FileShortName, num(FileSize(FileLongName),'# ### ### ###',',',' ') as FileSize, FileTime(FileLongName) as FileTime, // ************ Exif Main (IFD0) Attributes ************ Attribute(FileLongName, 'ImageWidth') as ImageWidth, Attribute(FileLongName, 'ImageLength') as ImageLength, Attribute(FileLongName, 'BitsPerSample') as BitsPerSample, Attribute(FileLongName, 'Compression') as Compression,
// examples: 1=uncompressed, 2=CCITT, 3=CCITT 3, 4=CCITT 4,
//5=LZW, 6=JPEG (old style), 7=JPEG, 8=Deflate, 32773=PackBits RLE, Attribute(FileLongName, 'PhotometricInterpretation') as PhotometricInterpretation,
// examples: 0=WhiteIsZero, 1=BlackIsZero, 2=RGB, 3=Palette, 5=CMYK, 6=YCbCr, Attribute(FileLongName, 'ImageDescription') as ImageDescription, Attribute(FileLongName, 'Make') as Make, Attribute(FileLongName, 'Model') as Model, Attribute(FileLongName, 'StripOffsets') as StripOffsets, Attribute(FileLongName, 'Orientation') as Orientation,
// examples: 1=TopLeft, 2=TopRight, 3=BottomRight, 4=BottomLeft,
// 5=LeftTop, 6=RightTop, 7=RightBottom, 8=LeftBottom, Attribute(FileLongName, 'SamplesPerPixel') as SamplesPerPixel, Attribute(FileLongName, 'RowsPerStrip') as RowsPerStrip, Attribute(FileLongName, 'StripByteCounts') as StripByteCounts, Attribute(FileLongName, 'XResolution') as XResolution, Attribute(FileLongName, 'YResolution') as YResolution, Attribute(FileLongName, 'PlanarConfiguration') as PlanarConfiguration,
// examples: 1=chunky format, 2=planar format, Attribute(FileLongName, 'ResolutionUnit') as ResolutionUnit,
// examples: 1=none, 2=inches, 3=centimeters, Attribute(FileLongName, 'TransferFunction') as TransferFunction, Attribute(FileLongName, 'Software') as Software, Attribute(FileLongName, 'DateTime') as DateTime, Attribute(FileLongName, 'Artist') as Artist, Attribute(FileLongName, 'HostComputer') as HostComputer, Attribute(FileLongName, 'WhitePoint') as WhitePoint, Attribute(FileLongName, 'PrimaryChromaticities') as PrimaryChromaticities, Attribute(FileLongName, 'YCbCrCoefficients') as YCbCrCoefficients, Attribute(FileLongName, 'YCbCrSubSampling') as YCbCrSubSampling, Attribute(FileLongName, 'YCbCrPositioning') as YCbCrPositioning,
// examples: 1=centered, 2=co-sited, Attribute(FileLongName, 'ReferenceBlackWhite') as ReferenceBlackWhite, Attribute(FileLongName, 'Rating') as Rating, Attribute(FileLongName, 'RatingPercent') as RatingPercent, Attribute(FileLongName, 'ThumbnailFormat') as ThumbnailFormat,
// examples: 0=Raw Rgb, 1=Jpeg, Attribute(FileLongName, 'Copyright') as Copyright, Attribute(FileLongName, 'ExposureTime') as ExposureTime, Attribute(FileLongName, 'FNumber') as FNumber, Attribute(FileLongName, 'ExposureProgram') as ExposureProgram,
// examples: 0=Not defined, 1=Manual, 2=Normal program, 3=Aperture priority, 4=Shutter priority,
// 5=Creative program, 6=Action program, 7=Portrait mode, 8=Landscape mode, 9=Bulb, Attribute(FileLongName, 'ISOSpeedRatings') as ISOSpeedRatings, Attribute(FileLongName, 'TimeZoneOffset') as TimeZoneOffset, Attribute(FileLongName, 'SensitivityType') as SensitivityType,
// examples: 0=Unknown, 1=Standard output sensitivity (SOS), 2=Recommended exposure index (REI),
// 3=ISO speed, 4=Standard output sensitivity (SOS) and Recommended exposure index (REI),
//5=Standard output sensitivity (SOS) and ISO Speed, 6=Recommended exposure index (REI) and ISO Speed,
// 7=Standard output sensitivity (SOS) and Recommended exposure index (REI) and ISO speed, Attribute(FileLongName, 'ExifVersion') as ExifVersion, Attribute(FileLongName, 'DateTimeOriginal') as DateTimeOriginal, Attribute(FileLongName, 'DateTimeDigitized') as DateTimeDigitized, Attribute(FileLongName, 'ComponentsConfiguration') as ComponentsConfiguration,
// examples: 1=Y, 2=Cb, 3=Cr, 4=R, 5=G, 6=B, Attribute(FileLongName, 'CompressedBitsPerPixel') as CompressedBitsPerPixel, Attribute(FileLongName, 'ShutterSpeedValue') as ShutterSpeedValue, Attribute(FileLongName, 'ApertureValue') as ApertureValue, Attribute(FileLongName, 'BrightnessValue') as BrightnessValue, // examples: -1=Unknown, Attribute(FileLongName, 'ExposureBiasValue') as ExposureBiasValue, Attribute(FileLongName, 'MaxApertureValue') as MaxApertureValue, Attribute(FileLongName, 'SubjectDistance') as SubjectDistance,
// examples: 0=Unknown, -1=Infinity, Attribute(FileLongName, 'MeteringMode') as MeteringMode,
// examples: 0=Unknown, 1=Average, 2=CenterWeightedAverage, 3=Spot,
// 4=MultiSpot, 5=Pattern, 6=Partial, 255=Other, Attribute(FileLongName, 'LightSource') as LightSource,
// examples: 0=Unknown, 1=Daylight, 2=Fluorescent, 3=Tungsten, 4=Flash, 9=Fine weather,
// 10=Cloudy weather, 11=Shade, 12=Daylight fluorescent,
// 13=Day white fluorescent, 14=Cool white fluorescent,
// 15=White fluorescent, 17=Standard light A, 18=Standard light B, 19=Standard light C,
// 20=D55, 21=D65, 22=D75, 23=D50, 24=ISO studio tungsten, 255=other light source, Attribute(FileLongName, 'Flash') as Flash, Attribute(FileLongName, 'FocalLength') as FocalLength, Attribute(FileLongName, 'SubjectArea') as SubjectArea, Attribute(FileLongName, 'MakerNote') as MakerNote, Attribute(FileLongName, 'UserComment') as UserComment, Attribute(FileLongName, 'SubSecTime') as SubSecTime,
Attribute(FileLongName, 'SubsecTimeOriginal') as SubsecTimeOriginal, Attribute(FileLongName, 'SubsecTimeDigitized') as SubsecTimeDigitized, Attribute(FileLongName, 'XPTitle') as XPTitle, Attribute(FileLongName, 'XPComment') as XPComment,
Attribute(FileLongName, 'XPAuthor') as XPAuthor, Attribute(FileLongName, 'XPKeywords') as XPKeywords, Attribute(FileLongName, 'XPSubject') as XPSubject, Attribute(FileLongName, 'FlashpixVersion') as FlashpixVersion, Attribute(FileLongName, 'ColorSpace') as ColorSpace, // examples: 1=sRGB, 65535=Uncalibrated, Attribute(FileLongName, 'PixelXDimension') as PixelXDimension, Attribute(FileLongName, 'PixelYDimension') as PixelYDimension, Attribute(FileLongName, 'RelatedSoundFile') as RelatedSoundFile,
Attribute(FileLongName, 'FocalPlaneXResolution') as FocalPlaneXResolution, Attribute(FileLongName, 'FocalPlaneYResolution') as FocalPlaneYResolution, Attribute(FileLongName, 'FocalPlaneResolutionUnit') as FocalPlaneResolutionUnit,
// examples: 1=None, 2=Inch, 3=Centimeter, Attribute(FileLongName, 'ExposureIndex') as ExposureIndex, Attribute(FileLongName, 'SensingMethod') as SensingMethod,
// examples: 1=Not defined, 2=One-chip color area sensor, 3=Two-chip color area sensor,
// 4=Three-chip color area sensor, 5=Color sequential area sensor,
// 7=Trilinear sensor, 8=Color sequential linear sensor, Attribute(FileLongName, 'FileSource') as FileSource,
// examples: 0=Other, 1=Scanner of transparent type,
// 2=Scanner of reflex type, 3=Digital still camera, Attribute(FileLongName, 'SceneType') as SceneType,
// examples: 1=A directly photographed image, Attribute(FileLongName, 'CFAPattern') as CFAPattern, Attribute(FileLongName, 'CustomRendered') as CustomRendered,
// examples: 0=Normal process, 1=Custom process, Attribute(FileLongName, 'ExposureMode') as ExposureMode,
// examples: 0=Auto exposure, 1=Manual exposure, 2=Auto bracket, Attribute(FileLongName, 'WhiteBalance') as WhiteBalance,
// examples: 0=Auto white balance, 1=Manual white balance, Attribute(FileLongName, 'DigitalZoomRatio') as DigitalZoomRatio, Attribute(FileLongName, 'FocalLengthIn35mmFilm') as FocalLengthIn35mmFilm, Attribute(FileLongName, 'SceneCaptureType') as SceneCaptureType,
// examples: 0=Standard, 1=Landscape, 2=Portrait, 3=Night scene, Attribute(FileLongName, 'GainControl') as GainControl,
// examples: 0=None, 1=Low gain up, 2=High gain up, 3=Low gain down, 4=High gain down, Attribute(FileLongName, 'Contrast') as Contrast,
// examples: 0=Normal, 1=Soft, 2=Hard, Attribute(FileLongName, 'Saturation') as Saturation,
// examples: 0=Normal, 1=Low saturation, 2=High saturation, Attribute(FileLongName, 'Sharpness') as Sharpness,
// examples: 0=Normal, 1=Soft, 2=Hard, Attribute(FileLongName, 'SubjectDistanceRange') as SubjectDistanceRange,
// examples: 0=Unknown, 1=Macro, 2=Close view, 3=Distant view, Attribute(FileLongName, 'ImageUniqueID') as ImageUniqueID, Attribute(FileLongName, 'BodySerialNumber') as BodySerialNumber, Attribute(FileLongName, 'CMNT_GAMMA') as CMNT_GAMMA, Attribute(FileLongName, 'PrintImageMatching') as PrintImageMatching, Attribute(FileLongName, 'OffsetSchema') as OffsetSchema,
// ************ Interoperability Attributes ************ Attribute(FileLongName, 'InteroperabilityIndex') as InteroperabilityIndex, Attribute(FileLongName, 'InteroperabilityVersion') as InteroperabilityVersion, Attribute(FileLongName, 'InteroperabilityRelatedImageFileFormat') as InteroperabilityRelatedImageFileFormat, Attribute(FileLongName, 'InteroperabilityRelatedImageWidth') as InteroperabilityRelatedImageWidth, Attribute(FileLongName, 'InteroperabilityRelatedImageLength') as InteroperabilityRelatedImageLength, Attribute(FileLongName, 'InteroperabilityColorSpace') as InteroperabilityColorSpace,
// examples: 1=sRGB, 65535=Uncalibrated, Attribute(FileLongName, 'InteroperabilityPrintImageMatching') as InteroperabilityPrintImageMatching, // ************ GPS Attributes ************ Attribute(FileLongName, 'GPSVersionID') as GPSVersionID, Attribute(FileLongName, 'GPSLatitudeRef') as GPSLatitudeRef, Attribute(FileLongName, 'GPSLatitude') as GPSLatitude, Attribute(FileLongName, 'GPSLongitudeRef') as GPSLongitudeRef, Attribute(FileLongName, 'GPSLongitude') as GPSLongitude, Attribute(FileLongName, 'GPSAltitudeRef') as GPSAltitudeRef,
// examples: 0=Above sea level, 1=Below sea level, Attribute(FileLongName, 'GPSAltitude') as GPSAltitude, Attribute(FileLongName, 'GPSTimeStamp') as GPSTimeStamp, Attribute(FileLongName, 'GPSSatellites') as GPSSatellites, Attribute(FileLongName, 'GPSStatus') as GPSStatus, Attribute(FileLongName, 'GPSMeasureMode') as GPSMeasureMode, Attribute(FileLongName, 'GPSDOP') as GPSDOP, Attribute(FileLongName, 'GPSSpeedRef') as GPSSpeedRef,
Attribute(FileLongName, 'GPSSpeed') as GPSSpeed, Attribute(FileLongName, 'GPSTrackRef') as GPSTrackRef, Attribute(FileLongName, 'GPSTrack') as GPSTrack, Attribute(FileLongName, 'GPSImgDirectionRef') as GPSImgDirectionRef, Attribute(FileLongName, 'GPSImgDirection') as GPSImgDirection, Attribute(FileLongName, 'GPSMapDatum') as GPSMapDatum, Attribute(FileLongName, 'GPSDestLatitudeRef') as GPSDestLatitudeRef,
Attribute(FileLongName, 'GPSDestLatitude') as GPSDestLatitude, Attribute(FileLongName, 'GPSDestLongitudeRef') as GPSDestLongitudeRef, Attribute(FileLongName, 'GPSDestLongitude') as GPSDestLongitude, Attribute(FileLongName, 'GPSDestBearingRef') as GPSDestBearingRef, Attribute(FileLongName, 'GPSDestBearing') as GPSDestBearing, Attribute(FileLongName, 'GPSDestDistanceRef') as GPSDestDistanceRef,
Attribute(FileLongName, 'GPSDestDistance') as GPSDestDistance, Attribute(FileLongName, 'GPSProcessingMethod') as GPSProcessingMethod, Attribute(FileLongName, 'GPSAreaInformation') as GPSAreaInformation, Attribute(FileLongName, 'GPSDateStamp') as GPSDateStamp, Attribute(FileLongName, 'GPSDifferential') as GPSDifferential;
// examples: 0=No correction, 1=Differential correction, LOAD @1:n as FileLongName Inline "$(vFoundFile)" (fix, no labels); Next vFoundFile Next vExt
示例 3: Windows 媒体文件
此脚本读取文件夹 MyMusic 中所有可能的 WMA/WMV ASF 元标签。
/ Script to read WMA/WMV ASF meta tags for each vExt in 'asf', 'wma', 'wmv' for each vFoundFile in filelist( GetFolderPath('MyMusic') & '\*.'& vExt )
FileList: LOAD FileLongName, subfield(FileLongName,'\',-1) as FileShortName, num(FileSize(FileLongName),'# ### ### ###',',',' ') as FileSize, FileTime(FileLongName) as FileTime, Attribute(FileLongName, 'Title') as Title, Attribute(FileLongName, 'Author') as Author, Attribute(FileLongName, 'Copyright') as Copyright, Attribute(FileLongName, 'Description') as Description,
Attribute(FileLongName, 'Rating') as Rating, Attribute(FileLongName, 'PlayDuration') as PlayDuration, Attribute(FileLongName, 'MaximumBitrate') as MaximumBitrate, Attribute(FileLongName, 'WMFSDKVersion') as WMFSDKVersion, Attribute(FileLongName, 'WMFSDKNeeded') as WMFSDKNeeded, Attribute(FileLongName, 'IsVBR') as IsVBR, Attribute(FileLongName, 'ASFLeakyBucketPairs') as ASFLeakyBucketPairs,
Attribute(FileLongName, 'PeakValue') as PeakValue, Attribute(FileLongName, 'AverageLevel') as AverageLevel; LOAD @1:n as FileLongName Inline "$(vFoundFile)" (fix, no labels); Next vFoundFile Next vExt
示例 4: PNG
此脚本读取文件夹 MyPictures 中所有可能的 PNG 元标签。
// Script to read PNG meta tags for each vExt in 'png' for each vFoundFile in filelist( GetFolderPath('MyPictures') & '\*.'& vExt )
FileList: LOAD FileLongName, subfield(FileLongName,'\',-1) as FileShortName, num(FileSize(FileLongName),'# ### ### ###',',',' ') as FileSize, FileTime(FileLongName) as FileTime, Attribute(FileLongName, 'Comment') as Comment,
Attribute(FileLongName, 'Creation Time') as Creation_Time, Attribute(FileLongName, 'Source') as Source, Attribute(FileLongName, 'Title') as Title, Attribute(FileLongName, 'Software') as Software, Attribute(FileLongName, 'Author') as Author, Attribute(FileLongName, 'Description') as Description,
Attribute(FileLongName, 'Copyright') as Copyright; LOAD @1:n as FileLongName Inline "$(vFoundFile)" (fix, no labels); Next vFoundFile Next vExt