How to copy a file but change the extension

Hi,

I'm trying to create 2 buttons that can copy a file keeping it's name intact but changing the extension.
Essentially I want to be able to duplicate .psm1 files to .ps1 and visa versa.

So far I have Copy AS *.ps1 HERE
But this will create the file like : test.psm1.ps1
I've tried playing with the rename commands but these seem to bring up the GUI which I don't want .. i just want it to do the copy\rename silently.
Any help appreciated
Thanks
Damian

The Rename command only shows a GUI if it isn't given enough arguments to know what to do.

But if you want to copy rather than rename, try something like this:

Copy DUPLICATE PATTERN *.ps1 AS *.psm

And swap the extensions for the reverse.

That works on the selected files, creating .psm copies of any .ps1 files that are selected.

If you want it to work on all *.ps1 files in the current folder, without needing to select them, then replace PATTERN with FILE.

(Using HERE instead of DUPLICATE, like you were doing, may work as well. They are both quite similar.)

Awesome ! thanks Leo :grinning:
Works a treat, creates a new file in the same location as wanted, thanks for the info on doing it with all files.
But one at a time is all I need for now :+1:
Cheers
Damian

1 Like