🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #20218

Re: Skip Images or replace image content while keeping file name

#20218
From: Bill Clements
Date: Thu, 17 Oct 2002 19:02
104 lines
5571 bytes
Dropped the ball somewhere, and I can't find it. Can NE1 spot my mistake? 
--------------------------------------------- 
myNumberOfImages = 0 
myNumberOfPages = 0 
myTempCounter = 0 

'-------------------Get the number of JPG and TIF files in the folder.--------------------------- 
myNumberOfImages = 0 
For Each myFile In myFolder.Files 
    If (InStr(myFile.Name, ".JPG") <> 0) Or (InStr(myFile.Name, ".jpg") <> 0) Or (InStr(myFile.Name, ".TIF") <> 0) Or (InStr(myFile.Name, ".tif") <> 0) Then 
        myNumberOfImages = myNumberOfImages + 1 
        myImagesPlaced = myNumberOfImages 'For the Total MsgBox at the end. 
    End If 
Next 'get the next file 
'Number of Images in a folder is now known. 

'-------------------Get an accurate Page Count--(Last To First File)----------------------------- 
ImageCounter = 0 
For Each myFile In myFolder.Files 
    If (InStr(myFile.Name, ".JPG") <> 0) Or (InStr(myFile.Name, ".jpg") <> 0) Or (InStr(myFile.Name, ".TIF") <> 0) Or (InStr(myFile.Name, ".tif") <> 0) Then 

For ImageCounter = myNumberOfImages To 1 
    If (InStrRev(myFile.Name, "_1.JPG") <> 0) Or (InStrRev(myFile.Name, "_1.jpg") <> 0) Or (InStrRev(myFile.Name, "_1.TIF") <> 0) Or (InStrRev(myFile.Name, "_1.tif") <> 0) Then 
        myNumberOfPages = myNumberOfPages + 1 
        myNumberOfPSets = myNumberOfPSets + 1 
        If myTempCounter <> 0 Then 
            myNumberOfImagesInThisPSet = myTempCounter + 1 
            myPSet(myNumberOfPSets) = myNumberOfImagesInThisPSet 
            myTempCounter = 0 
        End If 
    Else 
        myTempCounter = myTempCounter + 1 
        If myTempCounter = 4 Then 
            myNumberOfFSets = myNumberOfFSets + 1 
            myNumberOfPages = myNumberOfPages + 1 
            myTempCounter = 0 
        End If 
    End If 
Next 
End If 
Next 



'Number of pages is now known. 
 'Number of images in each P set is now known 
 '------------------------------------------------------------------------------ 
 '------------------------------Set the number of pages in the document------------------------- 
myDocumentPreferences.NumberOfPages = myNumberOfPages 
'------------------------------------------------------------------------------------------------ 

Set myViewPreferences = myDocument.ViewPreferences 

Rem Set the ruler origin to the page origin (i.e., not spread or spine) 
myViewPreferences.RulerOrigin = idPageOrigin 

Rem Make sure that the measurement units are in mm, if they aren't already. 
myViewPreferences.HorzMeasurementUnits = idMSMillimeters 
myViewPreferences.VertMeasurementUnits = idMSMillimeters 

Rem Reset the zero point. 
myDocument.ZeroPoint = Array(0, 0) 
'------------------------Put the files into a collection (array)-------------------------------- 
Rem Process the files in the folder and fill in the collection object with 
Rem pathname, filename, page, frame index, frame bounds, text frame bounds. 
Rem Each item in the collection carries all of the information it needs to 
Rem get it into the right place in the document. Ideally, one would create 
Rem and use a custom object for this, but that's a bit too complicated for 
Rem this example. 

myPageCounter = 1 
myFrameCounter = 1 
myFramesPerPages = 1 

Rem Process only JPG and TIF files. 
'------------------------------------------------------------------------- 
'Add each file to the collection. Each PSet(number of PSets) value is nown. 
For Each myFile In myFolder.Files 
    If (InStr(myFile.Name, ".JPG") <> 0) Or (InStr(myFile.Name, ".jpg") <> 0) Or (InStr(myFile.Name, ".TIF") <> 0) Or (InStr(myFile.Name, ".tif") <> 0) Then 
        myCollection.Add Array(myFile.Path, myFile.Name, myPageCounter, myImageBoundsArray(myFrameCounter - 1), myTextFrameBoundsArray(myFrameCounter - 1)) 
            If (InStrRev(myFile.Name, "_1,JPG")) <> 0 Then 
                myFramesPerPage = myPSet(myNumberOfPSets) 
                myFrameCounter = myFrameCounter + 1 
            Else 
                If myFrameCounter < myFramesPerPage Then 
                    myFrameCounter = myFrameCounter + 1 
                Else 
                    If myFramesPerPage = myPSet(myNumberOfPSets) Then 
                        myFramesPerPage = 4 
                        myFrameCounter = 1 
                        myPSet(myNumberOfPSets) = myPSet(myNumberOfPSets - 1) 
                        myPageCounter = myPageCounter + 1 
                    End If 
                myFrameCounter = 1 
                myPageCounter = myPageCounter + 1 
                End If 
            End If 
    End If 
Next 
'---------------------------------------------------------------------------------- 

Thanks 

Bill
Technical Details
Message-ID: <1de60ecc.14@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newspump.sol.net!news.maxwell.syr.edu!newsfeed-east.nntpserver.com!nntpserver.com!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1de60ecc.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,dfb25085c0b7ec89,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2002-10-21 03:56:41 PST
From: "Bill Clements" <clementsbill@hotmail.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newspump.sol.net!news.maxwell.syr.edu!newsfeed-east.nntpserver.com!nntpserver.com!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: Skip Images or replace image content while keeping file name
Message-ID: <1de60ecc.14@WebX.la2eafNXanI>
Date: Thu, 17 Oct 2002 12:02:16 -0700
References: <1de60ecc.-1@WebX.la2eafNXanI>
Lines: 131
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit