Solved I have one directory with 90,000+ image files.

October 17, 2012 at 08:09:17
Specs: Windows 7 Service Pack 2
I have 90,000+ images in one folder. I want to run a command to create folders using files' date and move files into the created folders. So the one directory will be broken into folders with YYYY-MM-DD folders

I have no programming ability.


See More: I have one directory with 90,000+ image files.

Report •


#1
October 17, 2012 at 12:53:44
✔ Best Answer
NOTE: Assumed files in the folder are images to be sorted.
Q&D VBScript:
Const startPath = "c:\totaly\legit\reason.to\have\so\many\images"

Set fso = CreateObject("Scripting.FileSystemObject")
For Each file In fso.GetFolder(startPath).Files
  dirName = FormatDate(file.DateCreated)
  WScript.Echo file & " -- " & dirName
  MakeDir fso, dirName
  On Error Resume Next
  file.Move dirName & "\"
  On Error Goto 0
Next 'file
WScript.Quit

Function FormatDate(d)
  FormatDate = DatePart("yyyy", d) & "-" & Right("0" & DatePart("m", d), 2) _
   & "-" & Right("0" & DatePart("d", d), 2)
End Function

Sub MakeDir(byRef fso, sPath)
  If Not fso.FolderExists(sPath) Then _
    fso.CreateFolder(sPath)
End Sub

How To Ask Questions The Smart Way


Report •
Related Solutions


Ask Question