cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
lwx228
Level VIII

How do I download images in bulk with JSL and save them with the name of the specified column?

For example, download the attached links and save these pictures to the C: directory.

 

2020-02-24_22-23.png

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How do I download images in bulk with JSL and save them with the name of the specified column?

Here is a very simple script that I believe will do what you want

Names Default To Here( 1 );

// Create a list of all of the images
imgList = {"http://data2.readoor.cn/files/3211195850f6ae/pdf/9213745e4f7c7b/3/859de8ee2b9187a0e73d764fd53466e4.jpg",
"http://data2.readoor.cn/files/3211195850f6ae/pdf/9213745e4f7c7b/3/.........",
"http://data2.readoor.cn/files/3211195850f6ae/pdf/9213745e4f7c7b/3/........."};

// Read in and write each of the images
For( i = 1, i <= N Items( imgList ), i++,
	img = Open( imgList[i], jpg );
	img << Save Image( "C:\image" || Char( i ) || ".jpg", jpg );
);

 The Open() and Save Image() functions are Documented with examples in the Scripting Index.  

Jim

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: How do I download images in bulk with JSL and save them with the name of the specified column?

Here is a very simple script that I believe will do what you want

Names Default To Here( 1 );

// Create a list of all of the images
imgList = {"http://data2.readoor.cn/files/3211195850f6ae/pdf/9213745e4f7c7b/3/859de8ee2b9187a0e73d764fd53466e4.jpg",
"http://data2.readoor.cn/files/3211195850f6ae/pdf/9213745e4f7c7b/3/.........",
"http://data2.readoor.cn/files/3211195850f6ae/pdf/9213745e4f7c7b/3/........."};

// Read in and write each of the images
For( i = 1, i <= N Items( imgList ), i++,
	img = Open( imgList[i], jpg );
	img << Save Image( "C:\image" || Char( i ) || ".jpg", jpg );
);

 The Open() and Save Image() functions are Documented with examples in the Scripting Index.  

Jim
lwx228
Level VIII

Re: How do I download images in bulk with JSL and save them with the name of the specified column?

  • Thank Jim!
  • I used to write it this way, but it didn't work.

request = New HTTP Request(	Url("http://data2.readoor.cn/files/3211195850f6ae/pdf/2977675e4e6cb5/3/f0df50279eeaa6465bfaf4e93525e81a.jpg",jpg),
	Method( "GET" ),
);
img  = request << Send;
img << SaveImage( "C:/1.jpg", jpg ); 
lwx228
Level VIII

Re: How do I download images in bulk with JSL and save them with the name of the specified column?

dt=Current Data Table();
imgList = Column( "url" ) << get values;
For( i = 1, i <= N Row(dt), i++,
	img = Open( imgList[i], jpg );
	img << Save Image( "C:\image" || Char( i ) || ".jpg", jpg );
);