Rename Directory

I have a form that allows a user to change anything about a selected vehicle.  When the vehicle is first added it creates a folder on the server.  The name of the folder is the VIN number.  My question is if a user changes the vin because they put the wrong vin in.  How would I rename the directory.

Below is the code I use to create the original directory.

    <cfset vin = #form.vin#>
    <cfset destination="c:\coldfusion8\wwwroot\automotive\photos\"&#vin#&"\" >
   
    <cfif Not DirectoryExists(destination) >
      <cfdirectory action="create" directory="#destination#" >
    </cfif>
sonicimpulseAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

duncancummingCommented:
<cfdirectory action="rename">
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_d-e_03.html

I assume you're also storing this information in the database?  When they update the details, check if the vin number has changed from what is in the database.  If it has, rename it.

<cfquery name="checkVin" datasource="dsn">
	SELECT vin
	FROM Vehicles
	WHERE id = #form.id#
</cfquery>
 
<cfif checkVin.vin NEQ form.vin>
<!--- it's changed --->
	<cfdirectory 
		action="rename"
		directory="c:\coldfusion8\wwwroot\automotive\photos\#checkVin.vin#\" 
		newDirectory="c:\coldfusion8\wwwroot\automotive\photos\#form.vin#\">
</cfif>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sonicimpulseAuthor Commented:
I'm not getting any errors but its not changing the name of the directory.  I even tried putting # signs around form.vin in the if statement.
0
duncancummingCommented:
You don't need the # # in a cfif statement.  Paste in all your code you're using, and we'll identify where the problem is.
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

sonicimpulseAuthor Commented:
<cfquery name="checkVin" datasource="#DSN#">
        SELECT vin
        FROM Vehicles
        WHERE idvehicles = #form.id#
</cfquery>
 
<cfif checkVin.vin NEQ form.vin>
<!--- it's changed --->
        <cfdirectory
                action="rename"
                directory="c:\coldfusion8\wwwroot\automotive\photos\#checkVin.vin#\"
                newDirectory="c:\coldfusion8\wwwroot\automotive\photos\#form.vin#\">
</cfif>
0
sonicimpulseAuthor Commented:
I got it working.  I got rid of the query and added a hidden field that stores the original vin.
0
sonicimpulseAuthor Commented:
Thanks for the help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.