Rename a file

Help with writing and running scripts

Rename a file

Postby slouw » Tue Mar 24, 2009 4:27 pm

Hi There
I want to rename the active document by adding some text to the end of the filename.
Often this text would be in the clipboard but maybe I would generate a popup to enter the text.
Generating the popup to prompt for the text is the one thing I have managed.
That proves that I have looked at the help!
I have also looked through the set of scripting commands and see nothing obvious to help.
Indeed there seems to be no menu based command.
I see some possibility with the runTool command and other vaguely relevant commands are newFile and saveAs.
Am I missing something here?
I presume this is best done my scripting and not a macro? (Macros looked even less promising...)

Thanks for any reply.
slouw
Newbie
 
Posts: 3
Joined: Tue Mar 24, 2009 4:18 pm

Re: Rename a file

Postby Mofi » Fri Mar 27, 2009 7:18 am

Yes, File - Rename File is yet (UE v14.20.1.008) not available as script or macro command. So there is no other possibility then using a user tool. Save As is not good because it does not delete the original file and therefore is not a real replacement for a file rename operation.

You would need to save and close the active file, create a new file where to insert

"full path of just saved file" "new file name without path"

select that string and run the tool which has the command line:

ren %sel%

Then you can close the temp file without saving it and open the file with the new name. Of course you don't get back with this method anything about success or failure of the rename done by Windows command ren. You would need to capture the output of the ren command and evaluate it with the script if you need to know also if the rename operation was successful.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4055
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Scripts