Copy link to clipboard
Copied
Hi,
I recive a usedcars.CSV file everyday for different dealers and i have to add/remove/change the data it to my MSSQL Database.
But the CSV file only has the link for 1 images of each cars but the systems that sends me the .CSV adds a lot more then that so i figure out how to get more images but i never know how many there is, could be 1 to 15 images.
Here is the code to get the images.
<cfset theclient = #client_number#>
pathimage1 = IS provided in the CSV file
<cfset pathimage2 = http://www.thedomain/images2/> They put it in a separate directory.
CSVData = is my query to the CSV file to get there ID and image path
<cfoutput query="CSVData">
<cfhttp
method="Get"
url="#pathimage1#"
path="c:\inetpub\mypath\"
file="#theclient#_#id#_1.jpg"></cfhttp>
<cfloop index="LoopCount" from="1" to="15">
<cfset loppcount2 = #loopcount# +1>
<cfhttp
method="Get"
url="#pathimage2#/#id#_#LoopCount#.jpg"
path="c:\inetpub\mypath\"
file="#theclient#_#id#_#loppcount2#.jpg"></cfhttp>
</cfloop>
</cfoutput>
So it creates empty .JPG for all of them but i dont know how many there is, what i need to do is delete the files that are less then 1k and count how many good ones there are for each record and add that number in my DB.
I'm using Coldfusion 7
Unless there is another way to do this ?
Thanks
Copy link to clipboard
Copied
Ok i got it to work maybe not the best way but i'm no expert.
<cfset imagecounter = 1>
<cfoutput query="CSVData">
<cfhttp
method="Get"
url="#pathimage1#"
path="c:\inetpub\mypath\"
file="#theclient#_#id#_1.jpg"></cfhttp>
<cfloop index="LoopCount" from="1" to="15">
<cfset loppcount2 = #loopcount# +1>
<cfhttp
method="HEAD"
url="mypath/#id#_#LoopCount#.jpg"></cfhttp>
<CFIF #cfhttp.statusCode# EQ '200 OK'>
<cfhttp
method="GET"
url="thepath/#id#_#LoopCount#.jpg"
path="c:\inetpub\mypath\"
file="#theclient#_#id#_#loppcount2#.jpg"></cfhttp>
<cfset imagecounter = #imagecounter# + 1>
</cfif>
</cfloop>
</cfoutput>