View Full Version : Batch Process
12-02-2003, 03:03 PM
At my work we have a HUGE amount of files that need to be exported with our new exporter but that means that somebody is going to have to sit and open every scene and then export and move onto the next,
Is it possible to write a script that would open a file from a specific folder and then export it with the exact same name but a different filetype into another specified location and then open the next file in the folder and continue this untill all files had been exported??
Would really appreciate any help on this one, we have over 1000 files and i would hate to think that somebody will have to sit and do this, Thankfully it will not be me though, :)
Cheers in advance
12-02-2003, 03:29 PM
Hey. I'm at work at the moment, so I can;t really work on anything right now. But if you like, I will try to write something for you tonight.
The idea is:
Open given directory
Apply custom command (that you define) to all files of certain type
is that OK for you? The custom command will be a MEL command (or series of) that you define.Should have something by tomorrow (and those were his last words....;))
[EDIT] the latest version of the script can always be found at www.jhavna.net/code.htm
or at the last post of this thread
12-02-2003, 03:45 PM
thanks dude, this will be Unbelievably helpful if you can do this, dont know how to thank you enough.
Yeah, to simplify what i need:-
-Open file from Directory
-ExportAll with same name as the orig Maya file
-open next file in directory
-Export file with same name as the orig Maya file
12-02-2003, 03:48 PM
No problem. I just started learning MEL and need some ideas and practice...
The bit where you say:
ExportAll with same name as the orig Maya file
That will have to be written by the user (only once though). The script will then just execute this on each file.
That still ok?
12-02-2003, 04:31 PM
" That will have to be written by the user (only once though). The script will then just execute this on each file.
That still ok? "
hhmmm, if it exports with the same name all the time it would save over the last file or am i misunderstanding you?
I am also just starting to learn mel but i am an artist and have not really done any programing before so i have lots to learn.
I would still like you to try and do what you think will work, even if its not exactly what i need it will be a strat and we can figure out anything we need to change to get it to do what i need, this could help us both learn.
if you dont mind that is.
12-02-2003, 10:02 PM
Well, I got caught a bit short of time, but managed to get an early alpha to you.
You can get it here www.jhavna.net/scripts/repeater.zip
It's really rough, as this is the first time I have touched UI and File stuff in MEL, but I am working on improving it (once I have more time). In the meantime, I hope this will suffice for your task. When I update it, I will post it here again.
First off, as it stands, the script will open your files, run your script (that I will call user script) and then close the file.
If you want it to save to different file names, I guess you can put that into the user script (i.e rename the file/scene before Repeater saves it)... But I have not had chance to test that yet.
Normal running procedure is:
Open file A
execute user-script (simple eval call)
Close file A
what you put in the script is up to you. The close/Save is just a simple file -save command. So I guess you could issue rename commands before it in the user script that you enter
If you want to run your script on all mb files in c:\projects simply enter
c:\projects\ (the final \ is important)
and hit ok
As I said, it will overwrite the original files by default, so I suggest using the script on a copy of the files you want to run your script on if you need to keep the originals.
As I haven't had much chance to test it yet, I'd appreciate any comments, crits, moans or suggestions you may have... :)
Hope you enjoy...
12-03-2003, 09:29 AM
will have a look at it soon and get back to you.
12-03-2003, 11:00 AM
Hey, quick update. Added some new features. The UI still looks shoddy though. Sorry
let me know how you get on
12-03-2003, 01:01 PM
i am having a little trouble with it, I keep getting an error message-
// Error: Unsaved changes. //
I have the window open, i typed in the address then type in *.mb into the mask field cause i only want .mb file opened and finally typed in the new save address.
I did not use the section to input my own script as i was testing it.
Am i doing something wrong ??
12-03-2003, 01:23 PM
I think the problem is that it is trying to open a file that you have edited and not saved.
Try saving all files first and then running the script. That's the only way I have managed to reproduce the error.
Hope that helps
12-03-2003, 01:41 PM
i keep getting the error, i have tried saving the files directly into the folder and then doing the script onto that folder but it still says the same.
I have to get back to work now but ill try again later and get back to you.
one thing that needs to added though is the ability to Export the files as a different filetype (e.g. *.x )
I have tried to find out the command for exporting but every time i try it brigns up a window asking me to type in a name and this is not what i need.
i am a total noob when it comes to programming and Mel so it could be a simple thing to do, i dont know.
Keep up the good work though, i am very greatful you are helping.
12-03-2003, 01:45 PM
As I said, it's still a really rough tool. I'm still working on ironing out stuff, and I am thankful for you helping out and testing it!
It seems to work for me, although all I have done so far is run
move 12 0 0;
on my files...
I also noticed a problem when there is not user script, but that is already fixed and will be in the next iteration. Feel free to email me rather than posting here BTW.
Will also into looking into saving under different extensions.
Will let you know as soon as I have more
12-05-2003, 02:20 PM
V1.3 available. Lot's of improvements.
Any further comments, bug reports and suggestions welcome.
Hope you find it useful!
 fixed a small bug that didn't set the orrect save directory
01-16-2006, 08:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.