Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File Output in Powershell without Extension

Here is what I have so far:

Get-ChildItem "C:\Folder" | Foreach-Object {$_.Name} > C:\Folder\File.txt

When you open the output from above, File.txt, you see this:

file1.txt
file2.mpg
file3.avi
file4.txt

How do I get the output so it drops the extension and only shows this:

file1
file2
file3
file4

Thanks in advance!

EDIT

Figured it out with the help of the fellows below me. I ended up using:

Get-ChildItem "C:\Folder" | Foreach-Object {$_.BaseName} > C:\Folder\File.txt
like image 252
CaptHowdy Avatar asked Nov 13 '12 22:11

CaptHowdy


People also ask

How do I copy a file without an extension in PowerShell?

In Powershell you can use Copy-Item to copy a file and you can specify the sources and the targets fullname either with or without extension. In an open cmd window, type: for %A in (file. mov) do echo %~dpnA - %~xA - %~zA.

How do I find a file without an extension?

You can check the file extension from the Type column in Windows file explorer. Alternatively, you could right-click on the file and select Properties. You'll see the Type of file in the General tab of file properties. If it says File, you know that the file has no extension.


1 Answers

Get-ChildItem "C:\Folder" | Select BaseName > C:\Folder\File.txt
like image 92
Ansgar Wiechers Avatar answered Nov 02 '22 19:11

Ansgar Wiechers