I am trying to rename a group of files in a directory that all have a part in the filename I want removed later on. The example of names are:
- 123876.111thepartIwanttoremove.exe
- thisisatestfile.111thepartIwanttoremove.exe
this?392!.111thepartIwanttoremove.exe
thankyouall.222thepartIwanttoremove.exe
- test.222thepartIwanttoremove.exe
- whatis@d354.222thepartIwanttoremove.exe
My code is:
forfiles /S /M *.111thepartIwanttoremove.exe /C "cmd /c rename @file @fname.doc"
ren ???.111thepartIwanttoremove.* ???.doc
ren ????.111thepartIwanttoremove.* ????.doc
ren ?????.111thepartIwanttoremove.* ?????.doc (and so on)
forfiles /S /M *.222thepartIwanttoremove.exe /C "cmd /c rename @file @fname.jpg"
ren ???.222thepartIwanttoremove.* ???.jpg
ren ????.222thepartIwanttoremove.* ????.jpg
ren ?????.222thepartIwanttoremove.* ?????.jpg (and so on)
So for an example I want the file:
123876.111thepartIwanttoremove.exe
To look like this:
123876.doc
what function can I use to remove the .*thepartIwanttoremove.exe part of the name afterwards without writing so many lines with "?"?
Thank you very much for your help.