Saturday, June 24, 2017

#1 2017-04-18 09:52:06 am

Adam239
Member
Registered: 2016-10-13
Posts: 54

Numbers - Remove All Images from Document

Hi there,

Is it possible to write a script that removes all images from a numbers document?
I am working with a document that contains some company logos - it would be great if there was a way to delete anything that ends in .png or .jpg?


running Sierra 10.12.4

Offline

 

#2 2017-04-18 10:39:41 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3052

Re: Numbers - Remove All Images from Document

Applescript:

(*
for macScripter
Remove images whose name ends with ".jpg", ".jpeg", ".png"

CAUTION: it doesn't remove images inserted in cells.
I don't know how to get pictures pasted in cells.

Yvan KOENIG (VALLAURIS, France)
2017/04/18 17:19:35
*)


tell application "Numbers" to tell document 1
   repeat with s from 1 to count sheets
       tell sheet s
           repeat with i from (count every image) to 1 by -1
               set itsName to file name of image i
               if (itsName ends with ".jpg") or (itsName ends with ".jepg") or (itsName ends with ".png") then delete image i
           end repeat
       end tell # sheet s
   end repeat
end tell

Yvan KOENIG running Sierra 10.12.4 in French (VALLAURIS, France) mardi 18 avril 2017 17:39:27

Last edited by Yvan Koenig (2017-04-18 12:13:10 pm)

Offline

 

#3 2017-04-18 10:55:26 am

Adam239
Member
Registered: 2016-10-13
Posts: 54

Re: Numbers - Remove All Images from Document

Thanks for the reply Yvan,

Unfortunately that script isn't working. I'm getting a "cant get image 1 of table 1 of sheet 1 of document 1" error


running Sierra 10.12.4

Offline

 

#4 2017-04-18 12:14:31 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3052

Re: Numbers - Remove All Images from Document

Would behave better if you remove the instruction

Applescript:

tell table 1

which is not in my script roll


Yvan KOENIG running Sierra 10.12.4 in French (VALLAURIS, France) mardi 18 avril 2017 19:14:25

Offline

 

#5 2017-04-18 01:03:18 pm

Adam239
Member
Registered: 2016-10-13
Posts: 54

Re: Numbers - Remove All Images from Document

HAH! Oh yes.
Works perfectly, now I've followed the instructions properly!

Thanks Yvan  smile


running Sierra 10.12.4

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.036 seconds, 11 queries executed ]

RSS (new topics) RSS (active topics)