Got it working with the following code:
<html>
<head>
<title>Images Cleanup</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<!--- CONFIGURATION --->
<!--- Change these to suit your server --->
<cfset dsn = "mydsn">
<cfset imagesDirectory = "c:\inetpub\lanescollectibles\images">
<cfset imagesSubdirectories = "400,200,85">
<!--- SQL Server is not case-sensitive, so lanesid = lanesID --->
<cfset imageColumnName = "lanesid">
<!--- Change this to FALSE to really do the deletes... --->
<cfset testMode = true />
<!--- /CONFIGURATION --->
<!--- Get all of the filenames --->
<cfquery datasource="#dsn#" name="qGetFilenames">
SELECT #imageColumnName# FROM products
UNION
SELECT #imageColumnName# FROM dolls
</cfquery>
<!--- Turn the filenames into a list --->
<cfset fileNames = 'ValueList(qGetFilenames.#imageColumnName#)' />
<!---
Loop through the various image subdirectories doing cleanup
--->
<cfloop list="#imagesSubdirectories#" index="i">
<cfdirectory action="list" directory="#imagesDirectory#\#i#"
name="qDirectory">
<!---
Loop over the files in the directory, deleting any that isn't
in the list of existing files
--->
<cfoutput>
<cfloop query="qDirectory">
<cfif not listFind(fileNames, qDirectory.name)>
<cfif not testMode>
<cffile action="delete" file="#imagesDirectory#\#i#\#qDirectory.name#">
<cfelse>
Test Mode: #imagesDirectory#\#i#\#qDirectory.name# would be
deleted. <br />
</cfif>
</cfif>
</cfloop>
</cfoutput>
</cfloop>
</body>
</html>
Thank you to everyone that helped!!!
~ Donna
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:184636
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54