Automatically locate files for Batch Process

Corel Paint Shop Pro

Moderator: Kathy_9

Post Reply
mbray21
Posts: 8
Joined: Fri Mar 06, 2015 10:24 pm
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Dell Inc. 042P49 A01
processor: Intel Core i5-3470
ram: 4GB
Video Card: Intel HD Graphics
sound_card: Conexant SmartAudio HD
Hard_Drive_Capacity: 500GB
Monitor/Display Make & Model: ViewSonic VX2250wm-LED

Automatically locate files for Batch Process

Post by mbray21 »

Hi there,

I have regularly run Batch Process to convert TIFF files to compressed bitmaps for use in the MRP system (3 times/day), using PaintShop Pro X3 and the built-in "Black and White" script. I'm now being asked to run this overnight so that production supervisors can print production orders for newly designed parts before I arrive for work (the supervisors arrive at 6:30 and I don't arrive until 7:00). I have an automation program (AutoMate5) that can automatically import the TIFF files from our network, open PSP X3, and open the Batch Process command. The only snag I have is in the part in Batch Process where you have to hit the "Browse" button to browse to where the files are kept. Is there a way within PSP X3 to automate that browsing function and starting the batch process? Once I'm past that point I can have the entire process run automatically (import, browse, process, export).

Thanks in advance,
Michael
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: Automatically locate files for Batch Process

Post by LeviFiction »

All of my suggestions, use scripts. Others might suggest alternate

Can autoMate create or edit script files to include the names of all of the files that were downloaded? You can create a script that runs the batch process command with a preset list of file locations.

Another option would be to download all files to a specific location, then create a script that looks through a specific folder adding each filename found in it to the batch process list, finally move all of the files to a new location. This way you just have one specific script that does all the work.
https://levifiction.wordpress.com/
mbray21
Posts: 8
Joined: Fri Mar 06, 2015 10:24 pm
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Dell Inc. 042P49 A01
processor: Intel Core i5-3470
ram: 4GB
Video Card: Intel HD Graphics
sound_card: Conexant SmartAudio HD
Hard_Drive_Capacity: 500GB
Monitor/Display Make & Model: ViewSonic VX2250wm-LED

Re: Automatically locate files for Batch Process

Post by mbray21 »

Thanks for the suggestions. From what I can determine, there is some scripting capability in AutoMate. However, because I don't have the premium edition, this scripting capability is limited, so I'll have to play around to see what I can or cannot do. I already have several AutoMate scripts I currently use (which I inherited from my predecessor). One does the file import from the network to a folder on my hard drive. Another script exports the converted files to another network location. A third script deletes the original tiff files.
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: Automatically locate files for Batch Process

Post by LeviFiction »

Sorry, I didn't make myself clear. By script, I meant PaintShop Pro script. Not AutoMate script.

PaintShop Pro scripts are written in Python. Because of this the scripts can be made quite intelligent. In five or six lines I can make a script in PSP that will read all of the files in a single folder, add them to the batch process command, and run the batch on those images. I'll do up a quick video tonight showing how.

EDIT:

Okay so here is the video I was talking about. http://youtu.be/jWTWUBLd038

It demonstrates creating the batch process script, and how to make it work on a specific folder.

Also in the video I mention giving you the custom function in this post so you can just do a quick copy and paste.

Code: Select all

def list_files(path):
    # returns a list of names (with extension, without full path) of all files 
    # in folder path
    files = []
    for name in os.listdir(path):
        filename = os.path.join(path, name)
        if os.path.isfile(filename):
            files.append(filename)
    return files
https://levifiction.wordpress.com/
mbray21
Posts: 8
Joined: Fri Mar 06, 2015 10:24 pm
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Dell Inc. 042P49 A01
processor: Intel Core i5-3470
ram: 4GB
Video Card: Intel HD Graphics
sound_card: Conexant SmartAudio HD
Hard_Drive_Capacity: 500GB
Monitor/Display Make & Model: ViewSonic VX2250wm-LED

Re: Automatically locate files for Batch Process

Post by mbray21 »

Sorry for the late reply, but this project got put on the back burner for a while.

I've looked through your video several times and pretty much followed everything to the letter. When I try running the script, however, I keep getting the following error:
Executing RunScript
Traceback (most recent call last):
File "<string>", line 18, in Do
TypeError: 'function' object is unsubscriptable

When I look back at the script (see attached text file version), that line 18 refers to the location where the tiffs are located, as if the script still cannot access the files. Based on your video, the one difference I noticed is in the beginning, where you insert the "import os" into the script. Your video refers to your hard drive as "OS" not "Local Disk". I tried renaming the hard drive as "OS" but still got the error. I don't have any restrictions on the hard drive. Could I be missing something?

Thanks again for your help. It has been much appreciated!
Attachments
CONVERT-TIFFS2.txt
(6.06 KiB) Downloaded 261 times
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: Automatically locate files for Batch Process

Post by LeviFiction »

Import OS is not the name of the hard drive, it's the name of a library that allows you to access the harddrive. The library name will always be "os" no matter what your harddrive name is.

The problem is this line

Code: Select all

'FileList': list_files[u'C:\\Emergency\\Emergency\\tiff'], 
It should be

Code: Select all

'FileList': list_files(u'C:\\Emergency\\Emergency\\tiff'), 
Notice the use of parenthesizes instead of brackets to surround the path. In python '[]' denotes a list. But if you're calling a function, like we are, you need to use '()' around the parameters.

That should be all it is.
https://levifiction.wordpress.com/
mbray21
Posts: 8
Joined: Fri Mar 06, 2015 10:24 pm
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Dell Inc. 042P49 A01
processor: Intel Core i5-3470
ram: 4GB
Video Card: Intel HD Graphics
sound_card: Conexant SmartAudio HD
Hard_Drive_Capacity: 500GB
Monitor/Display Make & Model: ViewSonic VX2250wm-LED

Re: Automatically locate files for Batch Process

Post by mbray21 »

Oops, my bad. That did it. The adjustment you mentioned worked like a charm. Automatic batch process is working great now. I'll continue to monitor for the next few days, but I consider the case closed.

Thank you so much for your help and patience!
mbray21
Posts: 8
Joined: Fri Mar 06, 2015 10:24 pm
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Dell Inc. 042P49 A01
processor: Intel Core i5-3470
ram: 4GB
Video Card: Intel HD Graphics
sound_card: Conexant SmartAudio HD
Hard_Drive_Capacity: 500GB
Monitor/Display Make & Model: ViewSonic VX2250wm-LED

Re: Automatically locate files for Batch Process

Post by mbray21 »

After my initial success, I have had to revisit this issue. The parties that requested I do this batch process automatically on a schedule now want to be able to do it manually with one click. I see that this would involve one single batch file, basically. I have constructed such a batch file using AutoMate, but I keep running into a snag when the batch process in PSP completes. Namely, the AutoMate batch file hangs because it's waiting for confirmation that the PSP batch process has completed. I'm beginning to think that I will have to do this using a regular batch file in Windows or some other script, unless there's a way that PSP can send a signal or code or something to other programs that it has finished running a batch process. Can anyone shed some light on this new issue, or offer some advice?

Thanks in advance,
Michael
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: Automatically locate files for Batch Process

Post by LeviFiction »

At the very end of the script try adding this command

Code: Select all

    # Close PSP
    App.Do( Environment, 'ExitApp', { 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((9,0,0),1)
                }
            })
That command forces PSP to close. And it does so silently. Hopefully once PSP closes AutoMate should start working again. At least that's my hope.

This should be the last command in the PaintShop Pro Script.
https://levifiction.wordpress.com/
mbray21
Posts: 8
Joined: Fri Mar 06, 2015 10:24 pm
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Dell Inc. 042P49 A01
processor: Intel Core i5-3470
ram: 4GB
Video Card: Intel HD Graphics
sound_card: Conexant SmartAudio HD
Hard_Drive_Capacity: 500GB
Monitor/Display Make & Model: ViewSonic VX2250wm-LED

Re: Automatically locate files for Batch Process

Post by mbray21 »

Thanks for the input. I will try it out over the weekend and let you know.
mbray21
Posts: 8
Joined: Fri Mar 06, 2015 10:24 pm
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Dell Inc. 042P49 A01
processor: Intel Core i5-3470
ram: 4GB
Video Card: Intel HD Graphics
sound_card: Conexant SmartAudio HD
Hard_Drive_Capacity: 500GB
Monitor/Display Make & Model: ViewSonic VX2250wm-LED

Re: Automatically locate files for Batch Process

Post by mbray21 »

I finally had a chance to test the additional script, but it doesn't seem to be working. I've waited at least 15 minutes (as of this posting) and nothing has happened. I'm attaching a text file with the revised script for further analysis. Thanks again for your help to date.
Attachments
CONVERT-TIFFS3.txt
Revised script to run batch process then close PSP X3 after batch process completed.
(6.37 KiB) Downloaded 144 times
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: Automatically locate files for Batch Process

Post by LeviFiction »

Sorry, I forgot there was a function at the bottom of the script. So when I told you to place that command as the last command that gets run I wasn't as specific as I needed to be.

The command goes just after the BatchProcess command but just before the def FindFiles line.

So here is the script edited. You can see where I placed it.
Attachments
CONVERT-TIFFS3-1.txt
(6.37 KiB) Downloaded 144 times
https://levifiction.wordpress.com/
mbray21
Posts: 8
Joined: Fri Mar 06, 2015 10:24 pm
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Dell Inc. 042P49 A01
processor: Intel Core i5-3470
ram: 4GB
Video Card: Intel HD Graphics
sound_card: Conexant SmartAudio HD
Hard_Drive_Capacity: 500GB
Monitor/Display Make & Model: ViewSonic VX2250wm-LED

Re: Automatically locate files for Batch Process

Post by mbray21 »

No problem, I should've looked more closely myself. The suggested change works perfectly. My AutoMate script now works great from start to finish.

Thanks again for your help.
Post Reply