Skip to main content
Dec 5, 2012 1:29 PM UTC
Question

Ae javascript, move file to new folder

Dear sir:

I want to move a file (such: "c:\\test.txt") to a new folder, I use javascript:

var object = new ActiveXObject("Scripting.FileSystemObject");

var file = object.GetFile("C:\\test.txt");

file.Move("d:\\");

But this is not work? Can somebody tell me how?

Thank a lot!

Sincerely Yours

Ze-Yi  Hsu

This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

Inspiring
Feb 29, 2024 6:26 PM UTC

what if i just wanted to select the file in explorer after :
var directory = new Folder(directoryPath);
directory.execute();

Translate
Dan Ebberts
Community Expert
Community Expert
Dec 5, 2012 4:15 PM UTC

You should be able to do it like this:

var myFile = new File('/c/test.txt');

myFile.copy('/d/test.txt');

myFile.remove();

Check Adobe's JavaScript Tools Guide (available through the ExtendScript Toolkit help menu) for the file system access commands.

Dan

Translate
Dec 5, 2012 10:56 PM UTC

Dear Dan:

Thanks a lot!

Best

Translate
Lazlo_Hollyfeld
Inspiring
Dec 6, 2012 3:18 PM UTC

You can also use the system.callSystem() method.  Although the command string code you place inside that funciton is dependant on which OS you are running AE on, but I have found that if you are certain of the OS, it works pretty well because AE is letting the OS handle the file operation.

Translate