Hi guys,
I want to make an script to store all the texture images in the same folder. This are the variables in my script:
ext_Path = String with the path to the folder (C:\Users\me\Desktop\TextuFolder\)
filename_ext = Texture name and format (Texture1.jpg)
full_Path = The complete path wehere I'm storing the image (C:\Users\me\Desktop\TextuFolder\Texture1.jpg)
I just need the command to store the images in the selected path. Something like file() or saveImage(). But I'm really newbie in Python programing.
Thanks in advance.
Solved! Go to Solution.
Solved by osidedan. Go to Solution.
Hello! what you probably need to do is import the shutil python module, and then use the copyfile function from that module.
here's an example:
import shutil
shutil.copyfile('c:/source/test_image.png', 'c:/destination/test_image_copy.png')
of note, the following things have to exist for the copy to work:
1. the source FILE must exist.
2. the destination FOLDER PATH must exist.
Let me know if you need more info on any of that!
Edit: to clarify, shutil is a native python module, meaning it is just part of python, it's not something maya related. Python has a TON of native modules that you can import and use to do all kinds of things.
Hi!
First of all, thanks for your answer. I tried using your solution but I had an unexpected error:
And both things exists: destination folder (I get the path with a cmds.fileDialog2(...)) and the source image (cmds.ls(type="file")). I also tried doing it with the shutil.copy(src, dst) operation but the same error appears.
Thanks!
hmm, interesting. To narrow things down, I would recommend trying to doing a simple copy first. Not one that is part of your script, just a simple one liner of shutil.copy(), and just use strings for your source and destination. If that works, then we know that we need to make adjustments to your script. if that DOESN'T work, then there may be something corrupt with your Maya preferences, or the python install.
Try that super simple copy, and let me know your results!
Can't find what you're looking for? Ask the community or share your knowledge.