Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Ae javascript, move file to new folder

Guest
Dec 05, 2012 Dec 05, 2012

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

TOPICS
Scripting
4.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 05, 2012 Dec 05, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 05, 2012 Dec 05, 2012

Dear Dan:

Thanks a lot!

Best

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 06, 2012 Dec 06, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 29, 2024 Feb 29, 2024
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines