I have a folder full of files (.avi and .txt files):
MyVideo1-MyEncode.avi
MyVideo1.avi 16-05-2019 15-41-01.txt
My Video 2.avi
My Video 2.avi 16-05-2019 16-43-11.txt
My Video 3 [Summer]-MyEncode.avi
My Video 3 [Summer].avi 16-05-2019 17-57-24.txt
My Video 4-(Fall).avi
My Video 4-(Fall).avi 13-05-2019 19-29-16.txt
My Video 5-(Winter)-MyEncode.avi
My Video 5-(Winter).avi 11-05-2019 11-15-05.txt
If the .avi file includes "-MyEncode" in the filename, I would like to then copy this part of the string into the filename of the corresponding text file.
e.g.
"MyVideo1-MyEncode.avi" includes the text "-MyEncode" in the filename
so: "MyVideo1.avi 16-05-2019 15-41-01.txt"
should be renamed as: "MyVideo1-MyEncode.avi 16-05-2019 15-41-01.txt"
on the other hand:
"My Video 2.avi" does not contain the string "-MyEncode" so the corresponding .txt file should not be renamed.
I have a number of folders containing files like this.
Can anyone please help?
PS - If I makes things easier, I can rename the like of "My Video 3 [Summer]-MyEncode.avi" to "My_Video_3_[Summer]-MyEncode.avi" (i.e. to remove the spaces)