Page 1 of 2

Export several projects in the same time

Posted: 17 Oct 2018, 10:21
by prudprod
Hello, all my 280 clips are divide in each project. I'm looking for, if it exists, a way to exports each project in a same time without importing all my projects in a new one. Thanks a lot for answering…

Re: Export several projects in the same time

Posted: 18 Oct 2018, 10:13
by Clément
You can run tvpaint from the command line, or send commands to the active tvpaint instance via the command line like so:

tvpaint.exe "cmd=tv_warn Hello"
tvpaint.exe "script=script.grg"

You can write a bash or batch script depending on your OS that will explore a list of .tvpp files in a folder or listed in a file, and, for each of them, trigger a script that will load with tv_LoadProject followed by the appropriate export method.

Re: Export several projects in the same time

Posted: 18 Oct 2018, 10:38
by Clément
Here is a small sample using python, we can extend it together if you think it can fit your needs.

Code: Select all

import os
from subprocess import call

#path to tvpaint executable
tvpaint_path = '"C:\Program Files\TVPaint Developpement\TVPaint Animation 11 Pro (64bits)\TVPaint Animation 11 Pro (64bits).exe"'

#directory where tvpp files are stored.
tvpp_path="C:/Users/Clément/Documents/tvpp_directory/"

tvpp_entries = []
all_entries = os.scandir( tvpp_path )
for entry in all_entries:
    if entry.is_file():
        ext = entry.name.split( "." )[-1]
        if( ext == "tvpp" ):
            tvpp_entries.append( entry )

for tvpp_entry in tvpp_entries:
    print( tvpp_entry.name )
    call( tvpaint_path + ' "cmd=tv_warn ' + tvpp_entry.name + '"' )

Re: Export several projects in the same time

Posted: 18 Oct 2018, 10:53
by prudprod
Hello thanks a lot, but I just forgot informing you my Os. MacOS sierra 10.12.6

thanks a lot

J

Re: Export several projects in the same time

Posted: 18 Oct 2018, 10:58
by slowtiger
There was a time, decades ago, when most Mac programs came with their own suite of applescript commands which were accessible from outside. Oh, those were the days ... try that with that lame excuse for a scripting language which calls itself "Automator".

Re: Export several projects in the same time

Posted: 18 Oct 2018, 13:04
by Clément
prudprod wrote: 18 Oct 2018, 10:53 Hello thanks a lot, but I just forgot informing you my Os. MacOS sierra 10.12.6
thanks a lot
J
I thought so. That is why i gave you a python example instead. I don't know how comfortable you are with scripting, but what do you think about the sample i gave you ?

If you want, you can install Python 3.x for MacOS,
copy the script i wrote in a file named "whatever.py",
replace the tvpaint_path and tvpp_path variables to fit your install.
launch the script "whatever.py"

The tvpp_path points to a directory where your 280 tvpp should lie, this specific script makes tvpaint display the names of all the tvpp files in a popup, it is a first step before making tvpaint load and export the projects.

Re: Export several projects in the same time

Posted: 19 Oct 2018, 09:08
by prudprod
Hello

I did what you tell me I have to do, but I have some issue when I run the script. I'm not really confortable with scripts. Could you help me to fix it ?
this is what I wrote in Python ;


import os
from subprocess import call

#path to tvpaint executable
tvpaint_path = '"C:/Applications/TVPaint Animation 11 Pro.app"'
cmd_test = '"cmd=tv_warn Test"'

#directory where tvpp files are stored.
#tvpp_path = os.getcwd()
tvpp_path="C:/Users/jo/Desktop/CHECKER/07-EPILOGUE"

tvpp_entries = []
all_entries = os.scandir( tvpp_path )
for entry in all_entries:
if entry.is_file():
ext = entry.name.split( "." )[-1]
if( ext == "tvpp" ):
tvpp_entries.append( entry )

for tvpp_entry in tvpp_entries:
print( tvpp_entry.name )
call( tvpaint_path + ' "cmd=tv_warn ' + tvpp_entry.name + '"' )

Re: Export several projects in the same time

Posted: 19 Oct 2018, 15:20
by Clément
Hi,
Are you on windows now ? You seem to have mixed windows and mac paths.
i wrote this on windows initially so there was some changes to make in order to get it to work properly on mac, but this is what we have so far:

Code: Select all

import os
from subprocess import call

#cmd prefix
cmd_prefix = ''
print( os.name )
if os.name == 'posix':
	cmd_prefix = 'open -n -W -a '

#path to tvpaint executable
tvpaint_path = '"/Applications/TVPaint Animation 11 Pro.app"'

#directory where tvpp files are stored.
tvpp_path = "/Users/clem/Documents/tvpp"

tvpp_entries = []
all_entries = os.scandir( tvpp_path )
for entry in all_entries:
    if entry.is_file():
        ext = entry.name.split( "." )[-1]
        if( ext == "tvpp" ):
            tvpp_entries.append( entry )

for tvpp_entry in tvpp_entries:
    baked_command = cmd_prefix + tvpaint_path + ' --args ' + '"cmd=tv_warn ' + tvpp_entry.name + '"' + ' ' + '"cmd=tv_quit"'
    print( baked_command )
    os.system( baked_command )
Notice that text that is placed after a '#' is actually a comment that is not executed as code, so it should remain like that.
The only two lines you need to change are:
tvpaint_path = '"/Applications/TVPaint Animation 11 Pro.app"'
and
tvpp_path = "/Users/clem/Documents/tvpp"



notice the tvpaint_path has simple quotes ' and double quotes "
'"like this"'
in order for the script to work

the tvpaint_path should not change much: you can go in your app folder and see if it has a different name, but it shouldn't if you have 11 pro.
the tvpp_path should change, probably to something like "/Users/jo/Desktop/CHECKER/07-EPILOGUE"

Re: Export several projects in the same time

Posted: 19 Oct 2018, 15:22
by Clément
By the way, can you tell me more about your issue, like do you have an error message ? It could help.
Thanks ;)

Re: Export several projects in the same time

Posted: 19 Oct 2018, 15:57
by prudprod
import os
from subprocess import call

#path to tvpaint executable
tvpaint_path = '"C:/Applications/TVPaint Animation 11 Pro.app"'
cmd_test = '"cmd=tv_warn Test"'

#directory where tvpp files are stored.
#tvpp_path = os.getcwd()
tvpp_path="/Users/jo/Desktop/EPILOGUE"

tvpp_entries = []
all_entries = os.scandir( tvpp_path )
for entry in all_entries:
if entry.is_file():
ext = entry.name.split( "." )[-1]
if( ext == "tvpp" ):
tvpp_entries.append( entry )

for tvpp_entry in tvpp_entries:
print( tvpp_entry.name )
call( tvpaint_path + ' "cmd=tv_warn ' + tvpp_entry.name + '"' )


AND THE MESSAGE ERROR IS :

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>>
================= RESTART: /Users/jo/Desktop/test python.py =================
LO_PL276_V01.tvpp
Traceback (most recent call last):
File "/Users/jo/Desktop/test python.py", line 22, in <module>
call( tvpaint_path + ' "cmd=tv_warn ' + tvpp_entry.name + '"' )
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 304, in call
with Popen(*popenargs, **kwargs) as p:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 756, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1499, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '"C:/Applications/TVPaint Animation 11 Pro.app" "cmd=tv_warn LO_PL276_V01.tvpp"': '"C:/Applications/TVPaint Animation 11 Pro.app" "cmd=tv_warn LO_PL276_V01.tvpp"'
>>>

Re: Export several projects in the same time

Posted: 19 Oct 2018, 16:01
by Clément
Ok alors c'est très bon signe: ça veut dire que le chemin vers le dossier est bien reconnu
Le message d'erreur te dit ici qu'il a bien trouvé le dossier mais qu'il bloque a l'étape suivante: au moment d'envoyer les intructions à tvpaint.
Je vois que tu as laissé le C: à 'tvpaint_path = '"C:/Applications/TVPaint Animation 11 Pro.app"'
Comme tout à l'heure, tu peux drag le app de tvpaint depuis le dossier Applications dans un terminal pour avoir son chemin exact ( sans C: devant à priori puisque c'était seulement mon chemin sur windows, désolé d'avoir embrouillé avec ça )
Puis remplacer tvpaint_path= '"xxx"' avec le chemin idoine ( attention au simple quote ' puis double quote " comme dit plus haut.

Re: Export several projects in the same time

Posted: 19 Oct 2018, 16:02
by Clément
Tu peux essayer cette version:

import os
from subprocess import call

#cmd prefix
cmd_prefix = ''
print( os.name )
if os.name == 'posix':
cmd_prefix = 'open -n -W -a '

#path to tvpaint executable
tvpaint_path = '"/Applications/TVPaint Animation 11 Pro.app"'

#directory where tvpp files are stored.
tvpp_path="/Users/jo/Desktop/EPILOGUE"

tvpp_entries = []
all_entries = os.scandir( tvpp_path )
for entry in all_entries:
if entry.is_file():
ext = entry.name.split( "." )[-1]
if( ext == "tvpp" ):
tvpp_entries.append( entry )

for tvpp_entry in tvpp_entries:
baked_command = cmd_prefix + tvpaint_path + ' --args ' + '"cmd=tv_warn ' + tvpp_entry.name + '"' + ' ' + '"cmd=tv_quit"'
print( baked_command )
os.system( baked_command )

Re: Export several projects in the same time

Posted: 19 Oct 2018, 16:37
by prudprod
C'est bon le script marche sans erreurs !! donc bravo !! en revanche il se contente d'ouvrir les projets successivement. Une petite fenêtre s'ouvre, avec le nom du projet et un bouton"ok", je clique sur "OK" mais il n'exporte par de rendu il ferme le projet et passe au suivant…

Re: Export several projects in the same time

Posted: 19 Oct 2018, 18:47
by Clément
Super !
Oui, je voulais déjà m'assurer que ça fonctionne comme ça, maintenant on va pouvoir les exporter ! Plutôt que d'afficher le nom on va le charger et exporter avec les paramètres adéquats. Pourras-tu me dire comment tu souhaite exporter tes projets ?
Bon week-end

Re: Export several projects in the same time

Posted: 22 Oct 2018, 08:24
by prudprod
Salut Clémént. Ce que je compte faire est très simple : exporter tous les projets au même format dans un dossier adéquat. évidement l'idée c'est que je n'ai pas à cliquer sur "ok" sur chaque projet qui s'ouvre, qu'il lance tout seul la manip et qu'il les exportent tous d'un coup pour que j'aille boire des cafés pendant ce temps :wink: