I want to add a text (sample) to the end of specific file Before the Extension (in powershell or anything else)
for example:
file1.mp4 => file1(sample).mp4 ///
file2.mkv => file2(sample).mkv ///
and don’t do anything on other formats
tried this
Get-ChildItem *.mp4 | ForEach-Object {
Rename-Item -Path $_.Name -NewName "$($_.Name) (sample)$($_.extension)"
}
but it adds an addition file format to the name
>Solution :
Because .Name includes the extension. Try .BaseName which does not, e.g.:
-NewName "$($_.BaseName) (sample)$($_.extension)"