File.changePath not working

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
peteoconnell
Posts: 19
Joined: November 14th, 2004, 2:10 pm

Hi, according to the Object Model Viewer in the Extendscript Toolkit, the File class has a method called changePath which I can't get to work. For example, here I am trying to move a file from my desktop to my documents folder.

Code: Select all

var theFile = File("~/Desktop/theTextFile.txt")
theFile.changePath('~/Documents')
Anyone know why this doesn't work?
Pete
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

The changePath function is documented in the Javascript Tools Guide CS4.pdf

Firstly, it looks like the correct usage would be:

Code: Select all

var theFile = File("~/Desktop/theTextFile.txt")
theFile.changePath("~/Documents/theTextFile.txt")
But it appears that this function is only for changing the file path associated with the file object, not for actually moving the file. To move the file, you can do this:

Code: Select all

var theFile = File("~/Desktop/theTextFile.txt");
theFile.copy("~/Documents/theTextFile.txt");
theFile.remove();
Post Reply