daily pastebin goal
42%
SHARE
TWEET

The cfm

anarchos78 Apr 7th, 2013 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <cfprocessingdirective pageencoding="UTF-8">
  2.  
  3. <cfset directory = "D:/TEST_CF/">
  4. <cfdirectory directory="#directory#" name="files" action="list" type="file">
  5. <cfset filecount = #files.RecordCount#>
  6. <cfset divisor = 3>
  7. <cfset division = #filecount# / #divisor#>
  8. <cfset remainder = #filecount# MOD #divisor#>
  9. <cfset folders_to_create = Ceiling(#division#)>
  10.  
  11. <cfoutput>
  12.  
  13.         <cfif directoryExists(directory)>        
  14.                 <cfdirectory action="list" directory="#directory#" name="directories" recurse="true" type="dir" />
  15.         <cfloop query="directories">
  16.             <cfdirectory action="delete" directory="#directory#/#directories.name#" recurse="yes">
  17.         </cfloop>
  18.     </cfif>    
  19.    
  20.     <cfloop from="1" to="#folders_to_create#" index="i">
  21.         <cfdirectory
  22.          action="create"
  23.          directory="#directory#newfolder#i#">
  24.     </cfloop>
  25.    
  26.     <cfif folders_to_create EQ 1>
  27.         #folders_to_create#&nbsp;folder created
  28.     <cfelse>
  29.         #folders_to_create#&nbsp;folders created
  30.     </cfif>
  31.        
  32. </cfoutput>
  33.  
  34. <cfdirectory directory="#directory#" name="dirs" action="list" type="dir">
  35. <cfset dirsarray = ArrayNew()>
  36.         <cfloop query="dirs">
  37.                         <cfset ArrayAppend(dirsarray, directory & "\" & dirs.name)>
  38.             <!---<cfset ArrayAppend(dirsarray, dirs.name)>--->
  39.         </cfloop>
  40. <cfdump var="#dirsarray#" label="dirsarray">
  41. <cfset filearray = ArrayNew()>
  42.         <cfloop query="files">
  43.                         <!---<cfset ArrayAppend(filearray, directory & "\" & files.name)>--->
  44.             <cfset ArrayAppend(filearray, files.name)>
  45.         </cfloop>
  46. <cfdump var="#filearray#" label="filearray">
  47.  
  48. <cfinvoke
  49.    component="cfc/arraygroups"
  50.    method="arrayGroupsOf"
  51.    returnVariable="output">
  52.     <cfinvokeargument name="arrObj" value="#filearray#">
  53.     <cfinvokeargument name="intGroup" value="#divisor#">
  54.     <cfinvokeargument name="padding" value="">
  55. </cfinvoke>
  56.  
  57. <cfset folders_to_create = ArrayLen(output)>
  58.  
  59. <cfloop array="#dirsarray#" index="dir">      
  60.   <cfloop array="#filearray#" index="file">
  61.        <cffile action="move"
  62.          source="#directory#\#file#"
  63.          destination="#dir#\#file#">
  64.   </cfloop>          
  65. </cfloop>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top