Rename File and keep Extension

Hi Everyone -

I am trying to learn how to use KM - so I apologize for the lack of knowledge of how to make this work. I know I am missing a simple step, but I just am unable to locate the answer.

I am trying to simply rename a file, and keep the extension.

What I want to end up with is my file named: SA Backup_todays date.csv
(The file is already a CSV file)

Here is what I put together:

And this does exactly what I want, except the Extension. I would also like to move the file, but I don't know how to select the newly named file. Do I insert the Text from the "to" field in the step above my last action and then select a place to move it to?

Thanks for you patience.
Kayle

Hi again, Kayle,

No need to apologize for not already knowing this answer; this is one of this forum's chief purposes :slightly_smiling_face:

When adding a file's extension back to a renamed file like this, you need to make sure to include the period in between the file's name and its extension, so the renamed file's text should be

SA Backup_%ICUDateTime%MM-yy%.%Variable%LocalFileExt%

As for moving the newly renamed file, rather than using two separate "Move or Rename a File" actions, it's easier and more efficient to move and rename the file in the same step. In the example you show, if you just add the parent folder path to the "to" field, like so:

~/Documents/SA Backup_%ICUDateTime%MM-yy%.%Variable%LocalFileExt%

The file in the LocalFile variable will be both moved to the specified folder and renamed at the same time.

That said, if for any reason it isn't feasible to move and rename in a single step, or you just want to know how you would move a newly renamed file without also moving it, the answer is that you once again need to include the folder path of the renamed file. If you don't know in advance what that will be, the easiest way to do that is to save the parent folder to a variable in the "Split Path" action you're already using, and use that in the path of the renamed file to be moved in the top field of the "Move or Rename a File" action, like so:

%Variable%LocalParentFolder%/SA Backup_%ICUDateTime%MM-yy%.%Variable%LocalFileExt%

(note the / after the parent folder variable; you'll need to include it in order to ensure that the result is a proper file path)

4 Likes

Thanks Gabe!

I swear I tried putting the "." in exactly where you had it and it didn't work. Of course, now it does.

And the moving the file in one step is fantastic!

Cheers
Kayle

1 Like