Ae javascript, move file to new folder

Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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

Copy link to clipboard
Copied
Dear Dan:
Thanks a lot!
Best
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
what if i just wanted to select the file in explorer after :
var directory = new Folder(directoryPath);
directory.execute();

