Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

I need to read images file size and delete them

New Here ,
Jul 05, 2010 Jul 05, 2010

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>
empty_images.jpg

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

305
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 05, 2010 Jul 05, 2010
LATEST

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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources