Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell Batch Add/Append text to a file name

Tags:

powershell

I am trying to batch add text to the titles of several files in a folder. My code works for command line but not PowerShell:

for %a in (*.avi, *.mta) do ren "%a" "My Title - %a"

Could someone help me adapt this to powershell?


Basically I would like to perform the following actions:

Folder Contents:

001-episode.avi 002-episode.avi

I would like to add the name of the show to the file

ShowTitle-001-episode.avi ShowTitle-002-episode.ave

Thank you.

like image 718
Bash Avatar asked Jan 03 '23 23:01

Bash


1 Answers

Found this to work as well.

Dir | rename-item -newname  { "My Title -" + $_.Name }
like image 155
Bash Avatar answered Jan 05 '23 17:01

Bash