Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 30th, 2008, 02:17 PM
Newbie
 
Join Date: Sep 2008
Posts: 20
Default Change folders name using coldfusion scripts like cffile, read etc

I would like to change all my sub folders name within a main folder, how do I do that???
like: -
app1
amm1
ann1

to
app1pp
amm1pp
ann1pp

using cffile / read /write etc

(I am new to coldfusion scrtpts)
Reply
  #2  
Old September 30th, 2008, 11:30 PM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 12,774
Default

The first thing to do is check the Coldfusion documentation for cffile on the Adobe website. The action should be set to "rename".

If you get stuck, post back with the code that you tried.
Reply
  #3  
Old October 1st, 2008, 04:23 AM
Newbie
 
Join Date: Sep 2008
Posts: 20
Default

rename is to change name of file??? or name of folder

mainfolder/
app1
amm1
ann1

and inside this main folder there are also files
show.cfm
view.cfm

1. Folder name -- How do I read the folder name without the file name in a directory??

Current, I am using <cfdirectory directory="#ExpandPath( '..\..\..\..\0addResume\#aa1_addresumefirst#\' )#" action="list" name="currentDir"> to read the directory. But if I want to read the folder name with showing the file name

=====I would like to read all folder name only

Thanks
Reply
  #4  
Old October 1st, 2008, 11:46 AM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 12,774
Default

Sorry, I thought you wanted to rename files (I guess I didn't read carefully).

Use <cfdirectory action="rename" ...> to rename a directory. If you don't know all the names of the directories, and you want to list only directories, loop over the query returned by cfdirectory and check the type attribute. If it's "DIR", it's a directory.
Reply
  #5  
Old October 2nd, 2008, 03:58 AM
Newbie
 
Join Date: Sep 2008
Posts: 20
Default

I have done it as follows without the cfdirectory code as

==============================

Expand|Select|Wrap|Line Numbers
  1. <cfdirectory directory="#ExpandPath( '..\..\..\..\0addResume\from word to html2\' )#" action="list" name="rs">
  2.  
  3.   <cfloop query="rs">
  4.  
  5. <cfoutput> 
  6. <cfif rs.type IS "dir">
  7. #rs.name#
  8. <cffile action="rename" source="#dd##rs.name#" destination="#dd##rs.name#_pp">
  9. </cfif>
  10. <p>
  11. </cfoutput>
  12.  
============== it is running fine ======

If I want to use cfdirectory, how do I do it??

Expand|Select|Wrap|Line Numbers
  1. <cffile action="rename" source="#dd##rs.name#" destination="#dd##rs.name#_pp" attributes="normal">
  2. or
  3. <cfdirectory action="rename" source="#dd##rs.name#" destination="#dd##rs.name#_xxx" attributes="directory">
  4.  
it gives an error:-
Attribute validation error for the CFDIRECTORY tag.
When the value of the ACTION attribute is RENAME, the tag requires the attribute(s): DIRECTORY,NEWDIRECTORY.

Last edited by acoder; October 2nd, 2008 at 12:31 PM. Reason: Added [code] tags
Reply
  #6  
Old October 2nd, 2008, 12:34 PM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 12,774
Default

Instead of source and destination attributes, you need to use directory and newDirectory when using cfdirectory.

PS. please use code tags when posting code. Thanks.
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles