ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

IDEA: Moving selected files to date based folders

<< < (2/5) > >>

kartal:
I installed it and it does not do anything under xp, and it looks like it does not work on selected files


edit: It did not like non standard installation location. Installing under program files worked.

Sir Smiley, I use Day_Month_Year generally. Althou Year_Month_Day would be more applicable to directories I guess

Armando:
Year_Month_Day seems like the way to go for any classification, whether folders or files. Stuff get all mixed up otherwise -- years don't repeat, but days and month do, so it makes more sense.  :)

kartal:
I normally use light year but human years is fine in this case too :)

SirSmiley:
Next you'll want star date! ;)

Are you meaning moving into just one folder or a directory tree?

SirSmiley:
Here's a simple vbscript file with no recursion.


--- ---'*********************************************************
' Sorter.vbs
'
' 3:30 PM 11/04/2008
'
' A. Timperley aka SirSmiley
'
' Purpose:
' Sort Files Into Date Specific Folders. Creates folders if none exist.
' Non-Recursive. Eg. Doesn't do subfolders
' Inputs:
' Dropped Folders
' Returns:
' Msgbox notification on completion
'*********************************************************
'Year|Month|Day
Dim objArgs : Set objArgs = WScript.Arguments
Dim arrDropFldrs()
Dim arrDropFiles()

Dim blnRecurse : blnRecurse=False

Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
' Set the path to your target folder here
Dim objTargetFldr : objTargetFldr = "C:\Programming\Sandbox\x"
' Special character
' Use double quotes with no space if you wish to have a straight date
Dim sSC : sSC = "."
' Configure Sorting Method
' 1 = Date Created | 2 = Date Last Accessed | 3 = Date Last Modified
Dim iSortDate : iSortDate = 3

'Splits dropped folders into an array
' You can drop multiple folders this way
For I = 0 to objArgs.Count - 1
If I <0 Then
WScript.Quit
  Else
' Build Array from Dropped Items
ReDim Preserve arrDropFldrs(I)
arrDropFldrs(I)=objArgs(I)
  End If
  Call FilesToFolder
Next

' Checks to see if Target Date Folder Exists
' Creates one if none exists
Function DateFolder(strDate)
' Format Date
strSortDate = DatePart("yyyy",strDate)&sSC
If DatePart("m",strDate) < 10 Then
strSortDate = strSortDate & "0"
End If
strSortDate = strSortDate & DatePart("m",strDate)&sSC
If DatePart("d",strDate) < 10 Then
strSortDate = strSortDate & "0"
End If
strSortDate = strSortDate & DatePart("d",strDate)
strTargetFldr = objTargetFldr&"\"&strSortDate
If objFSO.FolderExists(strTargetFldr) Then
DateFolder=strTargetFldr&"\"
Else'If objFSO.FolderExists(strTargetFldr)=False Then
objFSO.CreateFolder(strTargetFldr)
DateFolder=strTargetFldr&"\"
End IF
End Function

' Creates File Collection from Folders in Array. Sorts Accordingly
Sub FilesToFolder
For i=0 To UBound(arrDropFldrs)
strFolder=arrDropFldrs(i)
' Get Folder
Set objFolder = objFSO.GetFolder(strFolder)
' Get's File Collection
Set objFileCol=objFolder.Files
For Each File In objFileCol
If iSortDate = 1 Then
strTargetFldr = DateFolder(File.DateCreated)
objFSO.MoveFile File,strTargetFldr
ElseIf iSortDate = 2 Then
strTargetFldr= DateFolder(File.DateLastAccessed)
objFSO.MoveFile File,strTargetFldr
ElseIf iSortDate = 3 Then
strTargetFldr= DateFolder(File.DateLastModified)
objFSO.MoveFile File,strTargetFldr
End If
Next
Next
msgbox "Complete"
End Sub

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version