File tree Expand file tree Collapse file tree 5 files changed +119
-0
lines changed
Expand file tree Collapse file tree 5 files changed +119
-0
lines changed Original file line number Diff line number Diff line change 1+ using System . Linq ;
2+ using System . Management . Automation ;
3+ using JetBrains . Annotations ;
4+
5+ namespace MetadataExtractor . PowerShell
6+ {
7+ [ Cmdlet ( "Extract" , "Metadata" ) ]
8+ [ UsedImplicitly ]
9+ public sealed class ExtractMetadata : PSCmdlet
10+ {
11+ [ Parameter ( Position = 0 , Mandatory = true , HelpMessage = "Path to the file to process" ) ]
12+ [ ValidateNotNullOrEmpty ]
13+ public string FilePath { get ; set ; }
14+
15+ [ Parameter ( HelpMessage = "Show raw value" ) ]
16+ public bool Raw { get ; set ; }
17+
18+ protected override void ProcessRecord ( )
19+ {
20+ base . ProcessRecord ( ) ;
21+
22+ WriteVerbose ( $ "Extracting metadata from file: { FilePath } ") ;
23+
24+ var directories = ImageMetadataReader . ReadMetadata ( FilePath ) ;
25+
26+ if ( Raw )
27+ {
28+ var obj = from dir in directories
29+ where ! dir . IsEmpty
30+ from tag in dir . Tags
31+ select new
32+ {
33+ Directory = dir . Name ,
34+ Tag = tag . Name ,
35+ RawValue = dir . GetObject ( tag . Type )
36+ } ;
37+
38+ WriteObject ( obj . ToList ( ) ) ;
39+ }
40+ else
41+ {
42+ var obj = from dir in directories
43+ where ! dir . IsEmpty
44+ from tag in dir . Tags
45+ select new
46+ {
47+ Directory = dir . Name ,
48+ Tag = tag . Name ,
49+ Description = tag . Description
50+ } ;
51+
52+ WriteObject ( obj . ToList ( ) ) ;
53+ }
54+ }
55+ }
56+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <Project ToolsVersion =" 14.0" DefaultTargets =" Build" xmlns =" http://schemas.microsoft.com/developer/msbuild/2003" >
3+ <PropertyGroup >
4+ <VisualStudioVersion Condition =" '$(VisualStudioVersion)' == ''" >14.0</VisualStudioVersion >
5+ <VSToolsPath Condition =" '$(VSToolsPath)' == ''" >$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath >
6+ </PropertyGroup >
7+
8+ <Import Project =" $(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition =" '$(VSToolsPath)' != ''" />
9+ <PropertyGroup Label =" Globals" >
10+ <ProjectGuid >96158958-7ca7-4bfc-a573-30f31e7f39a4</ProjectGuid >
11+ <RootNamespace >MetadataExtractor.PowerShell</RootNamespace >
12+ <BaseIntermediateOutputPath Condition =" '$(BaseIntermediateOutputPath)'=='' " >.\obj</BaseIntermediateOutputPath >
13+ <OutputPath Condition =" '$(OutputPath)'=='' " >.\bin\</OutputPath >
14+ <TargetFrameworkVersion >v4.6.1</TargetFrameworkVersion >
15+ </PropertyGroup >
16+
17+ <PropertyGroup >
18+ <SchemaVersion >2.0</SchemaVersion >
19+ </PropertyGroup >
20+ <Import Project =" $(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition =" '$(VSToolsPath)' != ''" />
21+ </Project >
Original file line number Diff line number Diff line change 1+ using System . Reflection ;
2+ using System . Runtime . CompilerServices ;
3+ using System . Runtime . InteropServices ;
4+
5+ // General Information about an assembly is controlled through the following
6+ // set of attributes. Change these attribute values to modify the information
7+ // associated with an assembly.
8+ [ assembly: AssemblyConfiguration ( "" ) ]
9+ [ assembly: AssemblyCompany ( "" ) ]
10+ [ assembly: AssemblyProduct ( "MetadataExtractor.PowerShell" ) ]
11+ [ assembly: AssemblyTrademark ( "" ) ]
12+
13+ // Setting ComVisible to false makes the types in this assembly not visible
14+ // to COM components. If you need to access a type in this assembly from
15+ // COM, set the ComVisible attribute to true on that type.
16+ [ assembly: ComVisible ( false ) ]
17+
18+ // The following GUID is for the ID of the typelib if this project is exposed to COM
19+ [ assembly: Guid ( "96158958-7ca7-4bfc-a573-30f31e7f39a4" ) ]
Original file line number Diff line number Diff line change 1+ {
2+ "version" : " 1.0.0-*" ,
3+
4+ "dependencies" : {
5+ "MetadataExtractor" : " *" ,
6+ "JetBrains.Annotations" : " 10.1.5" ,
7+ "System.Management.Automation" : " 6.1.7601.17515"
8+ },
9+
10+ "frameworks" : {
11+ "net40" : {}
12+ }
13+ }
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MetadataExtractor.Tools.Jpe
2222EndProject
2323Project ("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}" ) = "MetadataExtractor.Benchmarks" , "MetadataExtractor.Benchmarks\MetadataExtractor.Benchmarks.xproj" , "{E78F38A6-CB2F-47A0-9932-47224B3FD2FC}"
2424EndProject
25+ Project ("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}" ) = "MetadataExtractor.PowerShell" , "MetadataExtractor.PowerShell\MetadataExtractor.PowerShell.xproj" , "{96158958-7CA7-4BFC-A573-30F31E7F39A4}"
26+ EndProject
2527Global
2628 GlobalSection (SolutionConfigurationPlatforms ) = preSolution
2729 Debug| Any CPU = Debug| Any CPU
@@ -70,6 +72,14 @@ Global
7072 {E78F38A6-CB2F-47A0-9932-47224B3FD2FC} .Release| Any CPU .Build .0 = Release| Any CPU
7173 {E78F38A6-CB2F-47A0-9932-47224B3FD2FC} .Release| x64 .ActiveCfg = Release| Any CPU
7274 {E78F38A6-CB2F-47A0-9932-47224B3FD2FC} .Release| x64 .Build .0 = Release| Any CPU
75+ {96158958-7CA7-4BFC-A573-30F31E7F39A4} .Debug| Any CPU .ActiveCfg = Debug| Any CPU
76+ {96158958-7CA7-4BFC-A573-30F31E7F39A4} .Debug| Any CPU .Build .0 = Debug| Any CPU
77+ {96158958-7CA7-4BFC-A573-30F31E7F39A4} .Debug| x64 .ActiveCfg = Debug| Any CPU
78+ {96158958-7CA7-4BFC-A573-30F31E7F39A4} .Debug| x64 .Build .0 = Debug| Any CPU
79+ {96158958-7CA7-4BFC-A573-30F31E7F39A4} .Release| Any CPU .ActiveCfg = Release| Any CPU
80+ {96158958-7CA7-4BFC-A573-30F31E7F39A4} .Release| Any CPU .Build .0 = Release| Any CPU
81+ {96158958-7CA7-4BFC-A573-30F31E7F39A4} .Release| x64 .ActiveCfg = Release| Any CPU
82+ {96158958-7CA7-4BFC-A573-30F31E7F39A4} .Release| x64 .Build .0 = Release| Any CPU
7383 EndGlobalSection
7484 GlobalSection (SolutionProperties ) = preSolution
7585 HideSolutionNode = FALSE
You can’t perform that action at this time.
0 commit comments