Page 1 of 1
File.changePath not working
Posted: March 28th, 2009, 8:36 pm
by peteoconnell
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
Re: File.changePath not working
Posted: April 25th, 2009, 1:55 am
by Paul Tuersley
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();