Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to pull the names of files from a directory into a csv file with the following:

Get-ChildItem -name | % { [IO.Path]::GetFileNameWithoutExtension($_) } 
                                                  | Export-Csv users.csv

Using '% { [IO.Path]::GetFileNameWithoutExtension($_) }' to display the files with out extensions.

All I get is the following in return:


Any Ideas?

share|improve this question

What does the directory really look like? Guessing the dir does not have dirs named 12,10,13... It does help us help you when we know what you're working with.
Why not just use "basename"?

PS C:\temp\post> ls

    Directory: C:\temp\post

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---          3/5/2012   2:55 PM         72 mark.txt
-a---          3/5/2012   2:55 PM         72 mike.txt
-a---          3/5/2012   2:55 PM         72 molly.txt
-a---          3/5/2012   2:57 PM         81 users.csv

PS C:\temp\post> gci | select baseName | export-csv users.csv -noTypeInfo

PS C:\temp\post> gc .\users.csv
share|improve this answer
using basename worked (i'd not used it before). Thank you :) – David Munoz Mar 6 '12 at 2:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.