Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

fileinfosystem members

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 01-31-2008   #1 (permalink)
IT Staff
Guest


 

fileinfosystem members

how do i use powershell to make use of the above class to get a file
EXTENSION ?

EXTENSION is a property.



My System SpecsSystem Spec
Old 01-31-2008   #2 (permalink)
Shay Levi
Guest


 

Re: fileinfosystem members


The above class doesn't exist, I guess you meant 'System.IO.FileInfo'


You can get a file extension with get-childitem

get-childitem *.* | foreach {$_.extension}




Or by using the underlying NET type get-childitem is using:

([System.IO.FileInfo]"C:\Scripts\test.txt").extension

get-childitem *.* | foreach { ([System.IO.FileInfo]$_).extension }




Or with System.IO.Path GetExtension method

get-childitem *.* | foreach { [System.IO.Path]::GetExtension($_) }




-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Quote:

> how do i use powershell to make use of the above class to get a file
> EXTENSION ?
>
> EXTENSION is a property.
>

My System SpecsSystem Spec
Old 02-02-2008   #3 (permalink)
Keith Hill [MVP]
Guest


 

Re: fileinfosystem members

"Shay Levi" <no@xxxxxx> wrote in message
news:8766a9441d3c48ca320cf9b07164@xxxxxx
Quote:

>
> The above class doesn't exist, I guess you meant 'System.IO.FileInfo'
>
Perhaps the OP is referring to FileSystemInfo which is the base class shared
by both DirectoryInfo and FileInfo. That is where Extension and a number of
other members common to both directories and files are defined.

BTW one of my favorite things to do with extension is group by it:

get-childitem -r | group Extension | sort count -desc

Quote:

> Or by using the underlying NET type get-childitem is using:
>
> ([System.IO.FileInfo]"C:\Scripts\test.txt").extension
>
> get-childitem *.* | foreach { ([System.IO.FileInfo]$_).extension }
Interesting approach. However that will generate errors on any
DirectoryInfo encountered. :-(

--
Keith

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
to enumerate all the members of a object M .NET General 2 03-01-2008 02:51 AM
Members of Group Nick PowerShell 9 02-28-2008 09:49 AM
How can I search for other members? Johnny Jet Live Messenger 1 12-01-2007 04:35 PM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51