GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Rename from script

Hi

My question is about the availability of something like 'FSUtil.Rename( src, dest )'

I have created a script which takes a path (parameter, or active tab) and recursively descends renaming every directory to a new name, then back.

(Why? I use a cloud service which occasionally gives permission errors when writing into directories. Renaming a directory, then renaming it back resets the permissions.. no clue why, and the cloud provider really hasn't been much help.)

While scanning, I call command.addLine("rename x to y") followed by command.addline("rename y to x") then command.Run() and check the return code. A single failure stops the loop.

However, any failure currently brings up the "rename" error dialog, and depending on what button I hit I sometimes end up in the Advanced Rename dialog.

I really want a simple rename() function which succeds or fails silently, and returns the result to my script.

Thanks heaps.

You can use the FileSystemObject for this sort of thing; it has a MoveFile method which lets you rename files directly.

Thanks for that.

Is there a Javascript variant of this? I'm a little thin on WScript so it might take me a while to figure out how to convert my script.

The object itself is language neutral, it can be used from any ActiveScripting language.

http://www.java2s.com/Tutorial/JavaScript/0600__MS-JScript/FileSystemObjectMoveFile.htm

Fantastic, Thanks for you help! I have everything working now, and can trap MoveFolder() errors internally. I've added calls to BusyIndicator() to show progress and allow me a way to cancel the process. Everything is working great.

Thanks again for your excellent support.

1 Like

A post was split to a new topic: Script BusyIndicator always on left side