Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automating Script for lots of files

Status
Not open for further replies.

mwvR

Technical User
Aug 1, 2002
8
0
0
GB
I'm after any help please with Python scripting advice. I've recorded my first script in PSP9 and have immediately hit a problem. The script is intended to open a .tif file, reduce the image size, and then to save as a .gif. The problem is that there are 255 files that I need to convert, and I don't want to record myself opening the 255 files and repeating the exact same steps. The constant is the image resize and saving as a .gif, the variable is the image file name. Is there some Python equivalent of the VBA code below (that opens all .xls files in a specific directory)?:

Sub LoopFiles()
Dim sDirectory As String
Dim sSpec As String
Dim sBook As String
Dim oBook As Workbook

sDirectory = "d:\files"
sSpec = "*.xls"
sBook = Dir(sDirectory & "\" & sSpec)
Do
Set oBook = Workbooks.Open(sDirectory & "\" & sBook)
''' Do your processing on oBook here (eg converting PSP9 files!)
oBook.Save
oBook.Close
sBook = Dir()
Loop Until sBook = ""
End Sub

Many thanks, Malachi
 
Sorry for this post - just found the BATCH options in PSP9. Apologies...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top