Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

The command

Table[Polt[Sin[k x],{x,1,10}],{k,1,30}]

generates a list of graphics. I want to export each list item as an individual jpg file, named according to the order of appearance in the list. How can I do this?

Thanks in advance.

share|improve this question

marked as duplicate by Mike Honeychurch, Artes, m_goldberg, Michael E2, rm -rf Nov 17 '13 at 6:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Have you tried anything, e.g. MapIndexed/Do $+$ Export? –  Kuba Nov 16 '13 at 10:21
    
Export created a jpg, containing all of the plots! I'm not familiar with MapIndexed/Do. –  Behzad Nov 16 '13 at 10:22
1  
Please fix up this question. Your code does not generate graphics. –  Mike Honeychurch Nov 17 '13 at 1:07

1 Answer 1

up vote 2 down vote accepted

Many ways to do this.

SetDirectory[NotebookDirectory[]];
data = Table[ Plot[Sin[k x], {x, 1, 10}], {k, 1, 3}];
Export[ToString[#] <> ".jpg", data[[#]]] & /@ Range[Length[data]]

Mathematica graphics

Or you can get a little fancy, and generate the names while building the table itself

data = Table[ {ToString[k] <> ".jpg", Plot[Sin[k x], {x, 1, 10}]}, {k,1, 3}];
Export[First[#], Last[#]] & /@ data

Have fun coming up with more ways.

share|improve this answer
    
Thanks dear Nasser. –  Behzad Nov 16 '13 at 10:28
2  
I would use IntegerString to generate numbers with leading zeros. That will make sure the files are sorted in the correct order when you list them. –  Sjoerd C. de Vries Nov 17 '13 at 8:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.