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
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.
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.
Get-ChildItem "C:\Folder" | Select BaseName > C:\Folder\File.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With