PSPX - looking for a script

Moderator: Kathy_9

Post Reply
hajo
Posts: 17
Joined: Wed May 11, 2011 11:42 am
operating_system: Windows XP Home
System_Drive: C
32bit or 64bit: 32 Bit

PSPX - looking for a script

Post by hajo »

Hello,
I am looking for a script for the following task:
*. cmx convert *. gif for a folder and its subfolders and their subfolders, if present.
Storing the gif files in the current folder / subfolder / subfolder.
Can anyone help?
greeting
hajo
joe1512
Posts: 22
Joined: Wed Oct 16, 2013 6:13 pm
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit

Re: PSPX - looking for a script

Post by joe1512 »

I am not very good with scripts, but here is what I would do in your situation:

1) Add a new Folder: Navigate to the top level Folder with the *.cmx files. Be sure to tell it to include all subdirectories.
It will then load up all your cmx images on the bottom strip.

From here, this looks pretty promiosing:
http://product.corel.com/help/PaintShop ... ingle=true

It looks like you can do the File, Batch Processing, hold Shift and select every single one of your cmx images.
Then, do a Save Mode, New Type, specify .gif.
Hit Start and off it goes.
hajo
Posts: 17
Joined: Wed May 11, 2011 11:42 am
operating_system: Windows XP Home
System_Drive: C
32bit or 64bit: 32 Bit

Re: PSPX - looking for a script

Post by hajo »

Are we talking of the same program (Paint Shop Pro X)?
There is no way to open a new folder by file batch processing.
There is no way to tell: include all subdirectories.
df
Posts: 1224
Joined: Mon Feb 08, 2010 11:21 pm
operating_system: Windows 11
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: GIGABYTE Z690 AERO G DDR4
processor: 13th Gen Intel Core i7-13700K
ram: 64gb
Video Card: RTX 3060 Ti 8gb GDRR6
Hard_Drive_Capacity: 1 Tb
Location: Washington State
Contact:

Re: PSPX - looking for a script

Post by df »

edit: ignore this and see Levi's response bellow.
A script will work on a single file. Batch processing will work on a batch of files, and can use a script doing do. i.e. create a script and batch processing will perform that script on the files that you specify, saving to the folder that you specify. It can't navigate folders and subfolders. You'd have to do that manually, but it would work the entire batch of files (that you specify) silently, so long as you have the execution mode set to silent and the steps in the script you've recorded not set to interactive. But it still won't navigate subfolders by itself, I don't know of any scripting program that can.

Please note, if you're looking for a batch resizing operation PSP isn't the best idea for that unless all of the donor files are the exact same size and orientation, and the output will be the exact same size and orientation.
Also, if the script calls a plug-in you'll have to approve the change in every single file that you process.
Last edited by df on Thu Jun 05, 2014 4:40 pm, edited 1 time in total.
Regards, Dan

"Smoke me a kipper, I'll be back for breakfast."
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: PSPX - looking for a script

Post by LeviFiction »

It is possible, if you know how to program using Python, to create a script that will batch process an entire folder as well as the sub folders.

This script would be run inside of PSP, not inside of the batch process folder.

Suz's Place is an excellent scripting resource. It shows examples of processing whole folders. - http://suzsplace.com/8scripts.htm

I don't have PSPX. So if I were to try and make a script, I could only guarantee that it would work with X6.

--------
EDIT: I've removed my comment on using batch processing. I recorded a video where I demonstrate how to create a script for processing a whole folder.

There are two things I would like to call your attention to, first is the fact that I didn't tell you where to save the script. In the Script Save Dialog you need to make sure you're saving the script to your Scripts-Trusted folder. Scripts-trusted is necessary because we're reading in a library, we're reading your HDD, and we're saving files. Scripts should not be allowed to do this, unless you trust them.

The second thing is that I stupidly mention that Python is case sensitive. That's specifically for variable and function names. Which means that MyVar is not the same thing as myvar. But with strings, or text, all programming languages are case sensitive. I just know some programmer is going to be on my case over that slip up.



It's 14 minutes long because I wasted time explaining how it works, and why I do things a certain way. But I also demonstrate the script in action.
https://levifiction.wordpress.com/
hajo
Posts: 17
Joined: Wed May 11, 2011 11:42 am
operating_system: Windows XP Home
System_Drive: C
32bit or 64bit: 32 Bit

Re: PSPX - looking for a script

Post by hajo »

Thanks for the replies. I'll need some time to process the proposals.
greeting
hajo
hajo
Posts: 17
Joined: Wed May 11, 2011 11:42 am
operating_system: Windows XP Home
System_Drive: C
32bit or 64bit: 32 Bit

Re: PSPX - looking for a script

Post by hajo »

Hello LeviFiction,

my attempt to create a script according to your video, brought the following error message:

'script could not be executed'

from JascApp import *
import os

def ScriptProperties():
return {
'Author': u'',
'Copyright': u'',
'Description': u'',
'Host': u'Paint Shop Pro X',
'Host Version': u'10.03'
}


def Do(Environment):
StartDir = u'W:\\NAS\\Hajo\\Bilder-fremde\\COREL5 Cliparts\\CLIPART'
extorg = u'.cmx'

for path, subdirs, files in os.walk(StartDir):
for filename in files:
filesource = os.path.join(path, filename)
name, ext = os.path.splitext(filesource)

if ext.lower() == extOrg:
saveToGif( Environment, filesource, name + ".gif")


def saveToGif( Environment, filesource, fileDest):
# EnableOptimizedScriptundo
App.Do( Environment, 'EnableOptimizedScriptUndo', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((10,0,3),1)
}
})

# FileOpen
App.Do( Environment, 'FileOpen', {
'FileList': [u'Z:\\Hajo\\TSW\\BANG_.CMX'],
'Folder': u'Z:\\Hajo\\TSW',
'FileFormat': App.Constants.FileFormat.Unknown,
'PluginFormat': 0,
'ShowPreview': True,
'EnableBrowser': True,
'FavFileList': [],
.
.
.



Do you have any advice?
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: PSPX - looking for a script

Post by LeviFiction »

Did the error say anything else? Like a line number or syntax error, or anything about a library problem? Was this a pop-up box, or did it say it in the script output palette?

One problem that I see is you have the variable "extorg" but when you do the comparison it's "extOrg" these, as far as Python is concerned, are two different variables. Always make sure the casing is the same. So either make them both lowercase or capitalize the "O" on both. But they must match.

Also, it looks like you didn't change the 'FileList' variable in the FileOpen command to filesource like you were supposed to either.

One last thing, did you make sure to save the script to your scripts-trusted folder? By default recorded scripts are placed into the Scripts-Restricted folder you have to manually change this or move it.
https://levifiction.wordpress.com/
hajo
Posts: 17
Joined: Wed May 11, 2011 11:42 am
operating_system: Windows XP Home
System_Drive: C
32bit or 64bit: 32 Bit

Re: PSPX - looking for a script

Post by hajo »

After the correction of your four points will be prompted to open the first file followed by the prompt to save the output file. This should be done automatically in the same folder as the input file.

I can not find the menu where I can enter 'Silent'.

Unfortunately I have no experience in writing a script.
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: PSPX - looking for a script

Post by LeviFiction »

Find every instance of

Code: Select all

'ExecutionMode': App.Constants.ExecutionMode.Default,
And change the last word from "Default" to "Silent"

Actually, find every place where ExecutionMode is used and set the mode to Silent. You can also just toggle execution mode using the script toolbar or inside the batch process, but this forces Silent mode regardless. So it's my preferred method.

Code: Select all

'ExecutionMode': App.Constants.ExecutionMode.Silent,
https://levifiction.wordpress.com/
hajo
Posts: 17
Joined: Wed May 11, 2011 11:42 am
operating_system: Windows XP Home
System_Drive: C
32bit or 64bit: 32 Bit

Re: PSPX - looking for a script

Post by hajo »

the script reads correctly, but what do I enter instead of
'FileName': u'Z:\\Hajo\\TSW\\BANG_.gif', '
to the output file output in the input folder?

Thank you in advance for your answer!


# FileSaveAs
App.Do( Environment, 'FileSaveAs', {
'Encoding': {
.
.
.

'GIF': {
'Interlaced': False,
'Version': App.Constants.GifVersion.Gif89a
},
.
.
.
'FileName': u'Z:\\Hajo\\TSW\\BANG_.gif',
'FileFormat': App.Constants.FileFormat.GIF,
'PluginFormat': 0,
'FormatDesc': u'GIF CompuServe Graphics Interchange',
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.AllAlways,
'Version': ((10,0,3),1)
},
'Plugin': {

},
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: PSPX - looking for a script

Post by LeviFiction »

Code: Select all

'FileName': fileDest,
Remember when creating the function we defined three parameters, Environment, filesource, and fileDest.

filesource holds the name of the source file.

fileDest holds the name of the new file you're saving to.

So all we do is replace the filename with fileDest and we're good to go.
https://levifiction.wordpress.com/
hajo
Posts: 17
Joined: Wed May 11, 2011 11:42 am
operating_system: Windows XP Home
System_Drive: C
32bit or 64bit: 32 Bit

Re: PSPX - looking for a script

Post by hajo »

So all we do is replace the filename with fileDest and we're good to go.

I'm sorry, but my knowledge is not enough.
All my attempts were not successful.

Can you give me an example in the right line?
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: PSPX - looking for a script

Post by LeviFiction »

Well, I show you directly in the video where to place those values.

Here is your original

Code: Select all

'FileName': u'Z:\\Hajo\\TSW\\BANG_.gif', 
'FileFormat': App.Constants.FileFormat.GIF, 
'PluginFormat': 0, 
'FormatDesc': u'GIF CompuServe Graphics Interchange', 
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Silent, 
'AutoActionMode': App.Constants.AutoActionMode.AllAlways, 
'Version': ((10,0,3),1)
Here I replaced the text u'Z:\\Hajo\\TSW\\BANG_.gif' with fileDest. This comes after the 'FileName': portion, but before the comma. The comma separates the individual settings so it has to be there to work.

This is what it looks like after I made the change

Code: Select all

'FileName': fileDest , 
'FileFormat': App.Constants.FileFormat.GIF, 
'PluginFormat': 0, 
'FormatDesc': u'GIF CompuServe Graphics Interchange', 
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Silent, 
'AutoActionMode': App.Constants.AutoActionMode.AllAlways, 
'Version': ((10,0,3),1)
https://levifiction.wordpress.com/
hajo
Posts: 17
Joined: Wed May 11, 2011 11:42 am
operating_system: Windows XP Home
System_Drive: C
32bit or 64bit: 32 Bit

Re: PSPX - looking for a script

Post by hajo »

Hello Levi fiction,

now runs the script properly.

Thank you for your effort and time that you have sacrificed me
Many greetings from Berlin, Germany to the U.S.

hajo

The following error occurred:
after a number of processed files, the internal memory of PSP is full.
Can you give me the code for closing the cmx files as well as the gif files?

a note to your youtube file:
multiply is a shadow over the image, so that the code is not readable.
Post Reply