?
Solved

Rename Directory

Posted on 2008-11-19
6
Medium Priority
?
346 Views
Last Modified: 2012-05-05
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>
0
Comment
Question by:sonicimpulse
  • 4
  • 2
6 Comments
 
LVL 16

Accepted Solution

by:
duncancumming earned 2000 total points
ID: 22996270
<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
 

Author Comment

by:sonicimpulse
ID: 22996602
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
 
LVL 16

Expert Comment

by:duncancumming
ID: 22996701
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:sonicimpulse
ID: 22997155
<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
 

Author Comment

by:sonicimpulse
ID: 22997501
I got it working.  I got rid of the query and added a hidden field that stores the original vin.
0
 

Author Closing Comment

by:sonicimpulse
ID: 31518337
Thanks for the help
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question