Skip to main content
December 5, 2012
Question

Ae javascript, move file to new folder

  • December 5, 2012
  • 2 replies
  • 4336 views

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 has been closed for replies.

2 replies

Inspiring
February 29, 2024

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

Dan Ebberts
Community Expert
Community Expert
December 5, 2012

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

December 5, 2012

Dear Dan:

Thanks a lot!

Best

Lazlo_Hollyfeld
Inspiring
December 6, 2012

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.