Change folders name using coldfusion scripts like cffile, read etc

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • freddie007
    New Member
    • Sep 2008
    • 20

    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)
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    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.

    Comment

    • freddie007
      New Member
      • Sep 2008
      • 20

      #3
      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="#Exp andPath( '..\..\..\..\0a ddResume\#aa1_a ddresumefirst#\ ' )#" action="list" name="currentDi r"> 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

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        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.

        Comment

        • freddie007
          New Member
          • Sep 2008
          • 20

          #5
          I have done it as follows without the cfdirectory code as

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

          Code:
          <cfdirectory directory="#ExpandPath( '..\..\..\..\0addResume\from word to html2\' )#" action="list" name="rs">
          
            <cfloop query="rs">
            
          <cfoutput> 
          <cfif rs.type IS "dir">
          #rs.name#
          <cffile action="rename" source="#dd##rs.name#" destination="#dd##rs.name#_pp">
          </cfif>
          <p>
          </cfoutput>
          ============== it is running fine ======

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

          Code:
          <cffile action="rename" source="#dd##rs.name#" destination="#dd##rs.name#_pp" attributes="normal">
          or
          <cfdirectory action="rename" source="#dd##rs.name#" destination="#dd##rs.name#_xxx" attributes="directory">
          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,NEWDI RECTORY.
          Last edited by acoder; Oct 2 '08, 11:31 AM. Reason: Added [code] tags

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            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.

            Comment

            Working...