I am trying to rename files in a directory from .ps5 format to .ps using a batch file. How can I rename the file and keep the original file name without having to manually putting the file name in the batch file. For example, if I put a file named 12345.ps5 into folder C:\RenameFile and run the batch file I would like the output file to be 12345.ps Are there some wildcards I could use to accomplish this?
-stephen
Keep Original File Name When Renaming File Extension
Moderator: DosItHelp
Re: Keep Original File Name When Renaming File Extension
This should do you!
Code: Select all
REN C:\RenameFile\*.ps5 *.ps
Re: Keep Original File Name When Renaming File Extension
Or you could use a loop.
Remove the ECHO command if you're sure it would work.
Regards
aGerman
Code: Select all
for %%i in (*.ps5) do ECHO ren "%%i" "%%~ni.ps"
Remove the ECHO command if you're sure it would work.
Regards
aGerman
Re: Keep Original File Name When Renaming File Extension
Sometimes we can have files with .ps1, .ps2, .ps3 etc. extensions. It's not the same file extension every time. How could I add all of these in the batch file and if it's a file with any of these extensions it will change it to the original file name plus the .ps extension?
Thanks
-stephen
Thanks
-stephen
Re: Keep Original File Name When Renaming File Extension
foxidrive wrote:This will rename any extension that starts with .ps
Off topic, yet can't help but notice that this would incidentally rename .ps1 files (usually associated in Windows with PowerShell) to .ps (PostScript). Yes, I realize that's exactly what's been asked, and guess it must make sense in some context somewhere.
Re: Keep Original File Name When Renaming File Extension
It's pretty common that nothing you see in a question represents the true task these days.