1
$\begingroup$

I was wondering if there was a python command that packs existing .blend files, without having to open them. For example having a folder full of 3d models with textures, videos , music, inside, I was wondering if we could all pack with a for loop without having to open 1x1 files.

Edit:

I simply ask if there is a python mode, through a for loop to access these .blend files already saved and in the case pack all the files inside them. I would just like to run this from a script on any project, even empty in the case.

If it does not exist, I also accept this answer, provided it is a correct answer.

$\endgroup$
1
$\begingroup$

You can do it using Blender in the GUI-less mode:

  • create a new Python script like this one (I'll call it pack_GUIless.py):

    import bpy

    bpy.ops.file.pack_all()

  • open the Command Prompt (Windows) or Terminal (Linux) and run the command blender --b [path_to_file]/test_file.blend -P [path_to_script]/pack_GUIless.py. You might have to put the blender path as well if you have a portable version of Blender. More info here:https://docs.blender.org/manual/en/latest/advanced/command_line/arguments.html

This will open blender in the terminal and close it as soon as the files of the test_file.blend project are packed, so it will be fast and clean (no GUI loaded). If you need to do it do it many times you might want to create a .cmd script to make it easier, like this one I made for rendering purposes (so you edit the script with the path to the .blend file and run it, and it will do everything by himself).

Please mind that I didn't test this specific case, so you might have to tweak something

$\endgroup$
4
  • 1
    $\begingroup$ I find this alternative useful, but rather wondered if there is possibility via a script executable in blender via a classic python script $\endgroup$
    – Noob Cat
    Oct 15 '19 at 22:01
  • $\begingroup$ I'm not sure what you mean: do you want to pack the assets of a project in a script that is open in a different project, or do you want to do it from a classic python console not related to blender? The answer could be to use the GUI-less command I showed you in a python subprocess, I guess, but I'm not that clear on the question $\endgroup$
    – Tareyes
    Oct 16 '19 at 20:15
  • $\begingroup$ I want to pack multiple .blend files by python script like addon script through any project, even empty, I would like to understand only if there is an api that allows it in blender. $\endgroup$
    – Noob Cat
    Oct 16 '19 at 22:34
  • 1
    $\begingroup$ No, .blender is not made to access other .blend files easily, but again, use a python subprocess. I never used them myself, but it's basically a way to start another script/program from python while the original one is still running. This way you can open other GUI-less Blender instance in background that open the specific files you want and pack their assets, then close. They will take a few seconds to do it, but the best thing about subprocesses is that you can continue working in Blender without any problem $\endgroup$
    – Tareyes
    Oct 17 '19 at 6:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.