check if render output file exsits

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
Norweschendir
Posts: 2
Joined: July 22nd, 2011, 6:48 am

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
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

You want newFile.exists, not exsits.
Norweschendir
Posts: 2
Joined: July 22nd, 2011, 6:48 am

aaah :roll: ok, sorry...
but still it doesn't work. i still got false back... :(
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

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...
   }
}
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

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
Post Reply