Page 1 of 1

check if render output file exsits

Posted: July 27th, 2011, 6:27 am
by Norweschendir
hey there,
i allready tried to search in this forum, but my all my search-phrases was filtered out by the search itself (exsit, file, output,...)

so, the problem:
i have a render script for AE and i set the render output path and file by this script. but at the moment i dont have a chance to check if the file i set by script is allready in the output folder. here is a part of the script:

Code: Select all

	var renderFilePath = "D:\06_AE_Render\073_Preview_20110727.mov"
	var newFile = new File(renderFilePath);
	if (newFile.exsits)
	{
		// do something if file exsits...
	} else {
		// do something else if file does not exsits...
	}
this script always return false, the file does not exsits, so to speak. in that renderFilePath var is the path and the filename given, as shown in the code above.
err... and by the way, the file exsits and is not corrupt. i've checked that a thousand times.

thx in advanced.
Norweschendir

Re: check if render output file exsits

Posted: July 27th, 2011, 10:08 am
by Paul Tuersley
You want newFile.exists, not exsits.

Re: check if render output file exsits

Posted: July 28th, 2011, 7:56 am
by Norweschendir
aaah :roll: ok, sorry...
but still it doesn't work. i still got false back... :(

Re: check if render output file exsits

Posted: July 28th, 2011, 8:10 am
by Paul Tuersley
It must be a problem with how you're writing your file path, but I'm not that familiar with the windows side of things.
This script should help you figure it out. Run the script and point it at the file in question to see the correct naming convention:

Code: Select all

var theFile = File.openDialog();

if (theFile != null) {

	alert("fsName = " + theFile.fsName + "\n\nabsoluteURI = " + File.decode(theFile.absoluteURI));

  //var renderFilePath = "D:\06_AE_Render\073_Preview_20110727.mov"
  //var newFile = new File(theFile.absoluteURI);
   var newFile = new File(theFile.fsName);
   if (newFile.exists)
   {
      // do something if file exsits...
	  alert("it exists");
	  alert("fsName = " + newFile.fsName + "\n\nabsoluteURI = " + File.decode(newFile.absoluteURI));
   } else {
	   alert("it doesn't exist");
      // do something else if file does not exsits...
   }
}

Re: check if render output file exsits

Posted: September 2nd, 2011, 8:02 am
by lloydalvarez
The problem is that the backslash is an escape character in javascript so your windows path:

Code: Select all

"D:\06_AE_Render\073_Preview_20110727.mov"
looks like this to javascript:

Code: Select all

"D:_AE_Render;_Preview_20110727.mov"
You can test this yourself with this simple code in ESTK:

Code: Select all

alert("D:\06_AE_Render\073_Preview_20110727.mov");
You can thank Bill Gates for choosing to do everything backwards to the way everyone else does this :-)

So you can either use forward slashes:

Code: Select all

"D:/06_AE_Render/073_Preview_20110727.mov"
Or escape the backslashes themselves (Depending on your code you might need more backslashes so make sure to test it in a controlled setting):

Code: Select all

"D:\\06_AE_Render\\073_Preview_20110727.mov"
On OS X this is not a problem as the paths are unix and are forward slashes to begin with.

Hope this helps.

-Lloyd