how do i add an extension to my files in a list?
$proj_files = (
"C:\test\122\338\7\1326647",
"C:\test\122\339\8\1326650"
)
ForEach ($file in $proj_files) {
$filenew = $file.Name + ".jpg"
Rename-Item $file $filenew
}
as with this I can get to add extensions to it, but it also then removes the name of the file so how do I just add the extension to it
$filenew
should just be ".jpg" above. This is because $file.Name
should be blank. The $file
object is a single string from the array of strings in $proj_files
. Remove .Name
and it will probably work fine.
If you want to know what $file
has, or is, pipe it to | Get-Member
.