Importing a file - path not valid

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
Athor
Posts: 11
Joined: July 7th, 2009, 5:18 pm

Alright I can finally post my problems here! (Waited about 4 months for the activation email :cry: )

I have written a file browser for the production I'm currently working on. It allows the compositors to click on the episode, sequence, shots and render version to quickly import the renders.

Image

It has been working fine but a little slow, because I have been using javascript to scan through all the renders in a folder (getFiles function seems really slow), and find out if the there are file sequences in that folder, then put the files into the end panel so a compositor can select them, then import.

So to speed it up I used command prompt to get a directory listing instead, and its a lot faster. The issue now is that when I go to import the file, I am getting an error saying Unable to set "file". Path is not valid" I can't see the full error because the extend script cuts it off. So the full path its trying to access doesn't appear. But if I do an alert of the path its a valid path and works fine.

I have been trying everything I can think of with no success.

This is the section of code giving me issues:

Code: Select all

var selectedFiles = (win.grp.mainBody.filesPnl.fileslistBox.selection);
				var selectedFilesLength = selectedFiles.length;
			
				
				for (var f=0; f<selectedFilesLength; f++)
				{
					var selectedFilesIndex = (win.grp.mainBody.filesPnl.fileslistBox.selection[f].index);
					var theSeq = new ImportOptions()
		
				
					theSeq.file = new File("H:/Episodes/"+ win.grp.mainBody.epPnl.eplistBox.selection.text + "/" + win.grp.mainBody.sqPnl.sqlistBox.selection.text + "/" + win.grp.mainBody.shPnl.shlistBox.selection.text + "/3d/maya/images/" + win.grp.mainBody.imgPnl.imglistBox.selection.text +"/" + firstFilesOriginal[selectedFilesIndex]);
	
			
					var importedFile = app.project.importFile(theSeq);
If I change the line where I define the file to have the file name at the end instead of getting it from an array it works:

Code: Select all

theSeq.file = new File("H:/Episodes/"+ win.grp.mainBody.epPnl.eplistBox.selection.text + "/" + win.grp.mainBody.sqPnl.sqlistBox.selection.text + "/" + win.grp.mainBody.shPnl.shlistBox.selection.text + "/3d/maya/images/" + win.grp.mainBody.imgPnl.imglistBox.selection.text +"/" +" LL02_S03_SH03_LITV04_RGB.0001.tif");
	

I would really appreciate some help because I am stumped!
Athor
Posts: 11
Joined: July 7th, 2009, 5:18 pm

Well I figured it out - the result from cmd prompt seemed to put a character at the end of the file name. When I escaped the string there was a %0D at the end. So I have just used this code to get around it:

Code: Select all

escapedFile = escape(sequences[f]);
importFile = escapedFile.slice(0,escapedFile.length-3);
Is there a better way to do it?
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

When I was writing my Immigration script I found that not only is the built in getFiles function very slow as you are pointing out, it also returns the files in random order on some server configurations making it useless for file sequence detection. Like you I ended up working around it although I wrote a new getFiles function using perl which I found is even faster the the unix ls command.

-Lloyd
sbaden
Posts: 35
Joined: June 16th, 2009, 1:07 pm
Location: Santa Clarita, CA

I think that the essence of my question is in this thread but I don't know enough about scripting yet to breakdown what you have and apply to my issue. Any help would be appreciated...


I am prompting the user to select a folder that has MOV's in it. I then want to import all MOV's one by one to replace the current MOV. The syntax I'm using isn't getting a list of MOV's in the folder.

Code: Select all

alert("Please select a folder with MOV's to be converted."); 
	var movLocation = folderGetDialog("Select folder with comps to be converted.");
	
	

var numMovs = movLocation.length;

for (i = 1; i<= numMovs; i++) {

	var movPath = movLocation.items[i];

	var originalMov = new File(movPath);
	
	convertFolder.item(1).replace(originalMov);
	
	
	
	// more script here
	
	
}
When I add an alert to tell me the number of MOV's in the folder it gives me, "undefined".
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

folderGetDialog is deprecated you should use Folder.selectDialog or Folder.selectDlg.

Code: Select all

var movLocation = Folder.selectDialog;
All that does, however, is get you a Folder object, if you want to get an array of the files in that folder you need to use the getFiles() function:

Code: Select all

var filesArray = movLocation.getFiles();
Lastly, the array returned begins at 0 so you need to start your loop at 0.

-Lloyd
sbaden
Posts: 35
Joined: June 16th, 2009, 1:07 pm
Location: Santa Clarita, CA

Thank you Lloyd, would this then work?

Code: Select all


alert("Please select a folder with MOV's to be converted."); 
	var movLocation = Folder.selectDialog("Select folder with comps to be converted.");
	
var filesArray = movLocation.getFiles();

for (i = 0; i<= filesArray.length; i++) {

	var movPath = filesArray[i];

	var originalMov = new File(movPath);
		
	convertFolder.item(1).replace(originalMov);
}
Last edited by sbaden on February 19th, 2010, 5:06 pm, edited 1 time in total.
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

Code: Select all

for (i = 0; i<= filesArray.length; i++) {

   var movPath = filesArray[i].fsName;

   var originalMov = new File(movPath);
      
   convertFolder.item(1).replace(originalMov);
      
}
sbaden
Posts: 35
Joined: June 16th, 2009, 1:07 pm
Location: Santa Clarita, CA

Cool. Thanks Lloyd!

A couple questions if you don't mind:

Why Folder.selectDialog instead of folderGetDialog?

And, what does fsName refer to?
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

Why don't you check out the scripting guide. It will answer those questions and so much more :-)

Lloyd
adamghering
Posts: 22
Joined: April 2nd, 2010, 1:14 am

lloyd,

Wondering if you can answer this for me. I have scoured the scripting guide and was wondering if there is any way to call to the preferences in a script. I work with multiprocessing a lot and I am getting tired of switching it from ram preview while working to rendering on output. I want to write a script that will set it to ram preview on startup but but then another one that runs as a pre-process to rendering that sets it to faster rendering. What are your thoughts?

thanks in advance,
Adam Ghering
Compositing Supervisor
Legend Films inc.
2D/3D Stereo Conversion
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

adamghering
Posts: 22
Joined: April 2nd, 2010, 1:14 am

nevermind I found it in one of your other posts...thanks though that was quick....need to write something proprietary any way...its for work and I can't purchase or install third party apps or scripts...which sucks because that includes most plugins unless I really battle through the red tape...grrrr. thanks for the help though.

cheers,
Adam Ghering
Compositing Supervisor
Legend Films inc.
2D/3D Stereo Conversion
Post Reply