PSP 8: ScriptRecording 'Save as'

Corel Paint Shop Pro

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

PSP 8: ScriptRecording 'Save as'

Post by hajo »

Hi,

this is the result of ScriptRecording 'Save as':

....................................................
from JascApp import *

def ScriptProperties():
return {
'Author': u'',
'Copyright': u'',
'Description': u'',
'Host': u'Paint Shop Pro',
'Host Version': u'8.10 Try&Buy '
}

def Do(Environment):
# EnableOptimizedScriptUndo
App.Do( Environment, 'EnableOptimizedScriptUndo', {

})

# FileSaveAs
App.Do( Environment, 'FileSaveAs', {
'Encoding': {
'JPG': {
'Variant': App.Constants.JpegFormat.Standard,
'CompressionFactor': 15,
'ChromaSubSampling': App.Constants.ChromaSubSampling.YCC_2x2_1x1_1x1
}
},
'FileName': u'H:\\Temp\\01-B-NC9018.jpg', #################
'FileFormat': App.Constants.FileFormat.JPG,
'FormatDesc': u'JPEG - JFIF Compliant',
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.AllAlways
},
'DefaultProperties': []
})

...............................................................................................

in connection with the script 'process directory', the files in a directory tree will be copied to another folder and keep their original names.
How do I have the entry 'filename': u'H: \ \ Temp \ 01-B-NC9018.jpg',' to change?

Thanks hajo
Joelle
Posts: 1815
Joined: Wed Apr 02, 2008 10:12 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Asus Prime B350M-A
processor: AMD Ryzen 5 1500 Quad-Core
ram: 16 GB RAM
Video Card: NVidia GeForce GTX 1050
Hard_Drive_Capacity: 1TB
Monitor/Display Make & Model: Samsung
Corel programs: PaintShop Pro X9
Location: UK

Re: PSP 8: ScriptRecording 'Save as'

Post by Joelle »

Sorry I know nothing about Scripting other than how to assemble them, so can't help, but you could ask in the cnews.corel.com groups.
There is a separate Scripting group:
corel.PaintShopPro_Scripting
Where Suz Shook, scripting supremo, might be able to help.

:-)
Joëlle
Joëlle
(PSPX9 )
Cassel
Posts: 1587
Joined: Fri Oct 29, 2010 6:49 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16Gb
Corel programs: PSP 8 (JASC) to PSP 2023
Location: Canada
Contact:

Re: PSP 8: ScriptRecording 'Save as'

Post by Cassel »

Without going into lenghty coding, one way to get the option to change the name of the file or its location is to replace the Execution Mode from Default, to Interactive. That means the script will wait for YOUR input, instead of doing it silently for you. If you are working in Batch mode, it would not be convenient, but beside recoding, it is the easiest solution.
Cassel
https://creationcassel.com/store
Specializing in PSP specific products: scripts and tubes

https://scrapbookcampus.com
for beginner and seasoned scrappers and designers and other PSP users
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: PSP 8: ScriptRecording 'Save as'

Post by LeviFiction »

You don't need to go into excessive code Cassel. Hajo made mention of the ProcessDirectory script which is found in the PSP9 scripting zip folder so most of the work is already done. The difference being Hajo wants to put it all into a new directory.

Using ProcessDirectory as a starting point the solution should be easy to answer.

First since ProcessDirectory already imports the os library you have everything you need except for the destination directory.

So create a variable that will hold the desitination. Let's call it DestDir. Go ahead and post it under the DirectoryToUse variable.

Now before you save go ahead and get the filename. The filename is inside the variable "File" inside that for loop.

Code: Select all

NameToUse = os.path.basename(File)
You can see I made the variable "NameToUse" and then used the function "os.path.basename()" to get the filename from the entire path currently used in the variable File.

So your FileName parameter in the SaveAs dialog would then look like this

Code: Select all

'FileName': os.path.join(DestDir, NameToUse), 
os.path.join() puts the directory path and the filename together into the proper syntax. You don't need to use this function but it makes sure that everything is correct for us and it's very easy to use so that's why I used it.

My only question, Hajo, is why are you trying to do this in a script? Why not use the Batch Process dialog? It has the capability of running a script on every image, so if you're using a script to get a special kind of change on the image you can do that without worrying about processing the directory yourself, and then saving it to a new location with the same name for you.

I can understand if you're just learning or if you have something specific you're doing with the directory that cannot be easily accomplished by batch processing, or if you're just learning. But know that you don't have to make a script process the entire directory when the Batch Process command will do it for you.
https://levifiction.wordpress.com/
teknisyan
Posts: 2421
Joined: Wed Oct 06, 2010 4:18 pm
operating_system: Windows 7 Home Premium
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Sony Corporation VAIO
processor: Intel Corel i5
ram: 4 GB
Video Card: ATI Mobility Radeon HD 5650
sound_card: Realtek HD Audio
Hard_Drive_Capacity: 500 GB
Location: Riyadh, KSA
Contact:

Re: PSP 8: ScriptRecording 'Save as'

Post by teknisyan »

Still learning scripting.. so I'll be in the audience with this one. :)
Like reading blogs?
About Tech
About Sports
Pnoy.Me - A URL Shortener
Follow me on Facebook & Twitter
Post Reply