18 Replies Latest reply on Jul 3, 2008 9:39 PM by Rajeev Kumar MIL

    IDCS2 -- Image File Name

    Rajeev Kumar MIL
      Dear All,

      Please see below code, I am trying to get the image name. But I am not getting it, please see the below code and suggest me.

      -----------------------
      tell application "Adobe InDesign CS2"
      set myDoc to front document
      tell myDoc
      set ImgCounter to get count of rectangle
      repeat with i from 1 to ImgCounter
      set ImgName to get file name of image 1 of rectangle i as string
      display dialog ImgName
      end repeat
      end tell
      end tell
      ---------------------
      Thanks
        • 1. Re: IDCS2 -- Image File Name
          sstanleyau Level 4
          On 1/7/08 5:43 PM, "rajeevkumar" <member@adobeforums.com> wrote:<br /><br />> set ImgName to get file name of image 1 of rectangle i as string<br /><br />If you look in the dictionary, you'll see that images don't have a 'file<br />name' property -- in fact, nothing in InDesign does. What you're looking for<br />is:<br /><br /> set ImgName to file path of item link of graphic 1 of rectangle i as string<br /><br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>
          • 2. Re: IDCS2 -- Image File Name
            Rajeev Kumar MIL Level 1
            Hi,
            Thanks a lot. Actually I was looking for missing images to display name only. Shall I use text delimiter to extract the name of the image or any other command to do it.

            Thanks
            • 3. Re: IDCS2 -- Image File Name
              Rajeev Kumar MIL Level 1
              Hi
              I have extracted the file name, can any one please tell me how to check for missing images.

              I have to check the missing images only.

              See the below code.

              ----------------------------
              tell application "Adobe InDesign CS2"
              set myDoc to front document
              tell myDoc
              set ImgCounter to get count of rectangle
              set Img_List to {}
              repeat with i from 1 to ImgCounter
              set ImgName to file path of item link of graphic 1 of rectangle i as string
              set AppleScript's text item delimiters to ":"
              set ImgName to last text item of (ImgName as string)
              set ImgName to ImgName & "
              "
              set AppleScript's text item delimiters to ""
              display dialog ImgName
              end repeat
              end tell
              end tell
              ---------------------------------
              Thanks
              • 4. Re: IDCS2 -- Image File Name
                sstanleyau Level 4
                You want something like:<br /><br />  name of every link whose needed is true and status is link missing<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>
                • 5. Re: IDCS2 -- Image File Name
                  Rajeev Kumar MIL Level 1
                  Hi,

                  Yes exactly I want the same, but it is not working. I am using InDesign CS2.

                  Thanks
                  • 6. Re: IDCS2 -- Image File Name
                    sstanleyau Level 4
                    Post the code that's not working.<br /><br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>
                    • 7. Re: IDCS2 -- Image File Name
                      Rajeev Kumar MIL Level 1
                      Hi,

                      Below is the code.

                      ---------------
                      tell application "Adobe InDesign CS2"
                      set myDoc to front document
                      tell myDoc
                      set ImgCounter to get count of rectangle
                      repeat with i from 1 to ImgCounter
                      set ImgName to get (name of every link whose needed is true and status is link missing)
                      display dialog ImgName
                      end repeat
                      end tell
                      end tell
                      ----------
                      Thanks
                      • 8. Re: IDCS2 -- Image File Name
                        sstanleyau Level 4
                        On 3/7/08 3:27 PM, "rajeevkumar" <member@adobeforums.com> wrote:<br /><br />> tell application "Adobe InDesign CS2"<br />> set myDoc to front document<br />> tell myDoc <br />> set ImgCounter to get count of rectangle<br />> repeat with i from 1 to ImgCounter<br />> set ImgName to get (name of every link whose needed is true and status is link<br />> missing) <br />> display dialog ImgName<br />> end repeat <br />> end tell <br />> end tell <br /><br />by referring to links, you're referring to all the links in a document --<br />you don't have to loop through rectangles or images. So:<br /><br />tell application "Adobe InDesign CS2"<br />tell front document<br />try<br />set ImgNames to (name of every link whose needed is true and status is link<br />missing) <br />set badImgCounter to count of ImgNames<br />repeat with i from 1 to badImgCounter<br />display dialog (item i of ImgName s)<br />end repeat <br />on error -- no missing images<br />display dialog "None found."<br />end error<br />end tell <br />end tell <br /><br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>
                        • 9. Re: IDCS2 -- Image File Name
                          Rajeev Kumar MIL Level 1
                          Hi,

                          It is showing error on the below line

                          display dialog (item i of ImgName s)

                          It is not taking the missing link name, only showing the "None found"

                          Thanks
                          • 10. Re: IDCS2 -- Image File Name
                            Rajeev Kumar MIL Level 1
                            Hi,

                            Now it is working fine, see the code below.

                            -----------
                            tell application "Adobe InDesign CS2"
                            tell front document
                            try
                            set ImgNames to (name of every link whose needed is true and status is link missing)
                            set badImgCounter to count of ImgNames
                            repeat with i from 1 to badImgCounter
                            display dialog {item i of ImgNames}
                            end repeat
                            on error -- no missing images
                            display dialog "None found."
                            end try
                            end tell
                            end tell
                            ---------
                            But Still there is a problem, it is not showing the complete file name.

                            It is showing all character of file name one by one. I want to display the complete file name.

                            Thanks
                            • 11. Re: IDCS2 -- Image File Name
                              Rajeev Kumar MIL Level 1
                              Hi,

                              Now it is showing the correct file name, I have made a minor change

                              display dialog ImgNames

                              But still a problem occurring.

                              It is showing the file name again & again, and if I cancel it, then it shows the dialog of "None found".

                              Please help me, in the time I am also looking in to the code.

                              Thanks
                              • 12. Re: IDCS2 -- Image File Name
                                sstanleyau Level 4
                                On 3/7/08 4:45 PM, "rajeevkumar" <member@adobeforums.com> wrote:<br /><br />> display dialog {item i of ImgNames}<br /><br />Change that back to:<br /><br />display dialog (item i of ImgNames)<br /><br />The problem you're having is that when there is only one missing image,<br />InDesign is returning just one name rather than a list of one name. So you<br />need to add this:<br /><br />if class of ImgNames is no list then set ImgNames to {ImgNames}<br /><br />straight after this line:<br /><br />set ImgNames to (name of every link whose needed is true and status is link<br />missing) <br /><br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>
                                • 13. Re: IDCS2 -- Image File Name
                                  Rajeev Kumar MIL Level 1
                                  Hi,

                                  Problem is still the same. If I am using the below code

                                  -----
                                  display dialog (item i of ImgNames)
                                  -----

                                  Then it shows the each character of file name.

                                  And If I am using the below code:

                                  ----
                                  display dialog ImgNames
                                  ----

                                  Then it shows the complete file names, but it gets repeated and repeated due to counter.

                                  I checked the below line

                                  set badImgCounter to count of ImgNames

                                  And badImgCounter is taking 18 values, and the Image File name is of 18 characters, so it is getting repeated 18 times.
                                  • 14. Re: IDCS2 -- Image File Name
                                    sstanleyau Level 4
                                    On 4/7/08 11:43 AM, "rajeevkumar" <member@adobeforums.com> wrote:<br /><br />> set badImgCounter to count of ImgNames<br />> <br />> And badImgCounter is taking 18 values, and the Image File name is of 18<br />> characters, so it is getting repeated 18 times.<br /><br />That means you haven't added the other line I suggested. Your code should<br />look like this:<br /><br />tell application "Adobe InDesign CS2"<br />tell front document<br />try<br />set ImgNames to (name of every link whose needed is true and status is link<br />missing) <br />if class of ImgNames is no list then set ImgNames to {ImgNames}<br />set badImgCounter to count of ImgNames<br />repeat with i from 1 to badImgCounter<br />display dialog (item i of ImgNames)<br />end repeat <br />on error -- no missing images<br />display dialog "None found."<br />end error<br />end tell <br />end tell <br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>
                                    • 15. Re: IDCS2 -- Image File Name
                                      Rajeev Kumar MIL Level 1
                                      Hi,

                                      Yes I tried what you have suggested and even I have using the above code. But It is showing the each character of image file name in display dialog.

                                      My concern is this, please check badImgName value it returns 18. Becuase the the file name is like this "C06-078A-888484.ai".

                                      Thanks
                                      • 16. Re: IDCS2 -- Image File Name
                                        sstanleyau Level 4
                                        It looks like I mis-typed "not" as "no" in:<br /><br />if class of ImgNames is not list then set ImgNames to {ImgNames}<br /><br />That line solves the problem buy making it a list if there's only one image.<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>
                                        • 17. Re: IDCS2 -- Image File Name
                                          Rajeev Kumar MIL Level 1
                                          Hi,

                                          Thanks now it is working exactly what I want.

                                          Thanks
                                          • 18. Re: IDCS2 -- Image File Name
                                            Rajeev Kumar MIL Level 1
                                            Hi,

                                            See the below code, I have just finished the code, but I am not getting the report generated.

                                            Please help me.

                                            ----------------------
                                            set source_folder to choose folder with prompt "Select folder containing InDesign Documents"
                                            tell application "Finder" to set item_list to every item of source_folder
                                            repeat with this_item in item_list
                                            set doc_kind to get kind of this_item
                                            if doc_kind contains "Indesign" then
                                            tell application "Adobe InDesign CS2"
                                            set user interaction level of script preferences to never interact
                                            open this_item
                                            set DocName to the name of document 1
                                            tell document 1
                                            set myfontprop to properties of every font
                                            set Font_List to {}
                                            repeat with i from 1 to the number of myfontprop
                                            set this_font_item to item i of myfontprop
                                            set myfontname to name of this_font_item as string
                                            set fontstatus to status of this_font_item as string
                                            set Font_List to Font_List & fontstatus
                                            end repeat
                                            if Font_List contains "not available" then
                                            my error_report(source_folder, DocName)
                                            -- else
                                            -- close document 1 saving no
                                            end if
                                            try
                                            set ImgNames to (name of every link whose needed is true and status is link missing)
                                            if class of ImgNames is not list then set ImgNames to {ImgNames}
                                            set badImgCounter to count of ImgNames
                                            repeat with i from 1 to badImgCounter
                                            my write_Report(DocName, ImgNames, source_folder)
                                            end repeat
                                            end try
                                            end tell
                                            close document 1 saving no
                                            end tell
                                            end if
                                            end repeat

                                            on error_report(source_folder, DocName)
                                            tell application "Finder"
                                            try
                                            set error_folder to (source_folder as string) & DocName & "_ErrorFolder" as alias
                                            on error
                                            tell application "Finder"
                                            make new folder at source_folder with properties {name:DocName & "_ErrorFolder"}
                                            set error_folder to (source_folder as string) & DocName & "_ErrorFolder" as alias
                                            end tell
                                            end try
                                            end tell
                                            tell application "Adobe InDesign CS2"
                                            tell document 1
                                            package to error_folder copying fonts no copying linked graphics no copying profiles no updating graphics no ignore preflight errors no creating report yes including hidden layers no
                                            -- close saving no
                                            end tell
                                            end tell
                                            tell application "Finder"
                                            try
                                            set text_file to (error_folder as string) & "Instruction.txt" as alias
                                            set the name of text_file to DocName & ".txt"
                                            end try
                                            end tell
                                            end error_report
                                            on write_Report(DocName, ImgNames, source_folder)
                                            set The_Report to source_folder & DocName & "Missing Images.txt"
                                            try
                                            open for access file the The_Report with write permission
                                            write ImgNames to file the The_Report starting at eof
                                            close access file the The_Report
                                            on error
                                            close access file the The_Report
                                            end try
                                            end write_Report
                                            -----------------