sylvain.fe...@ville-ge.ch wrote:
New in Python and coding. My goal :Apply recorded actions in Photoshop to many folders and subfolders containing images.My inspiration :Web page explaining a Python code using pywin32 : https://vsfxryan.com/portfolio/python-photoshop-action-scripts/, but I do not want to define functions, I am too much beginner for this.Problematic code :#run action script which opens the file, convert it to jpg, save and close it.psApp.DoAction( actionScript, 'jpg_q8') Error message : NameError: name 'actionScript' is not defined Could you please help me solve this?
Functions are fundamental to programming in general and Python in particular. You need to understand them if you're going to get anything done. Otherwise, you'll end up typing the same code over and over and over.
In this case, it looks like you are trying to run this code outside of the function it was defined in. The error is pretty much self-explanatory; you're trying to pass the value of the variable "actionScript" to the DoAction function, but there is no variable called "actionScript". Look at the code itself. You'll see that "actionScript" was passed in to the function as a parameter, because he wanted to be able to trigger different actions with the same code.
It should be clear that what you need to pass here is the action you want to take.
However, if you really need to script common actions to images and folders, I strongly suggest you take a look at the ImageMagick package. It is an incredible powerful photo manipulation tool that is all driven from the command line. It can be a bit tricky to set up the command lines, but once you do, it works the same way, time after time.
-- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc.
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32