Export several projects in the same time Topic is solved

Please use this part to report bugs & errors, ask questions & "How to..."
User avatar
prudprod
Posts: 45
Joined: 31 Mar 2006, 12:09
Contact:

Export several projects in the same time

Post 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…
User avatar
Clément
Posts: 93
Joined: 25 Jan 2017, 08:38

Re: Export several projects in the same time

Post 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.
Clement Berthaud, Software Developer, TVPaint Team
User avatar
Clément
Posts: 93
Joined: 25 Jan 2017, 08:38

Re: Export several projects in the same time

Post 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 + '"' )
Clement Berthaud, Software Developer, TVPaint Team
User avatar
prudprod
Posts: 45
Joined: 31 Mar 2006, 12:09
Contact:

Re: Export several projects in the same time

Post by prudprod »

Hello thanks a lot, but I just forgot informing you my Os. MacOS sierra 10.12.6

thanks a lot

J
User avatar
slowtiger
Posts: 2889
Joined: 08 May 2008, 21:10
Location: berlin, germany
Contact:

Re: Export several projects in the same time

Post 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".
TVP 10.0.18 and 11.0 MacPro Quadcore 3GHz 16GB OS 10.6.8 Quicktime 7.6.6
TVP 11.0 and 11.7 MacPro 12core 3GHz 32GB OS 10.11 Quicktime 10.7.3
TVP 11.7 Mac Mini M2pro 32GB OS 13.5
User avatar
Clément
Posts: 93
Joined: 25 Jan 2017, 08:38

Re: Export several projects in the same time

Post 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.
Clement Berthaud, Software Developer, TVPaint Team
User avatar
prudprod
Posts: 45
Joined: 31 Mar 2006, 12:09
Contact:

Re: Export several projects in the same time

Post 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 + '"' )
User avatar
Clément
Posts: 93
Joined: 25 Jan 2017, 08:38

Re: Export several projects in the same time

Post 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"
Clement Berthaud, Software Developer, TVPaint Team
User avatar
Clément
Posts: 93
Joined: 25 Jan 2017, 08:38

Re: Export several projects in the same time

Post 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 ;)
Clement Berthaud, Software Developer, TVPaint Team
User avatar
prudprod
Posts: 45
Joined: 31 Mar 2006, 12:09
Contact:

Re: Export several projects in the same time

Post 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"'
>>>
User avatar
Clément
Posts: 93
Joined: 25 Jan 2017, 08:38

Re: Export several projects in the same time

Post 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.
Clement Berthaud, Software Developer, TVPaint Team
User avatar
Clément
Posts: 93
Joined: 25 Jan 2017, 08:38

Re: Export several projects in the same time

Post 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 )
Clement Berthaud, Software Developer, TVPaint Team
User avatar
prudprod
Posts: 45
Joined: 31 Mar 2006, 12:09
Contact:

Re: Export several projects in the same time

Post 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…
User avatar
Clément
Posts: 93
Joined: 25 Jan 2017, 08:38

Re: Export several projects in the same time

Post 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
Clement Berthaud, Software Developer, TVPaint Team
User avatar
prudprod
Posts: 45
Joined: 31 Mar 2006, 12:09
Contact:

Re: Export several projects in the same time

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