Skip to main content
July 1, 2008
Question

IDCS2 -- Image File Name

  • July 1, 2008
  • 18 replies
  • 1566 views
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
This topic has been closed for replies.

18 replies

July 4, 2008
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
-----------------
July 4, 2008
Hi,

Thanks now it is working exactly what I want.

Thanks
Inspiring
July 4, 2008
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>
July 4, 2008
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
Inspiring
July 4, 2008
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>
July 4, 2008
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.
Inspiring
July 3, 2008
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>
July 3, 2008
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
July 3, 2008
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
July 3, 2008
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