Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Add text to the end of specific file

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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)" 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading