electricwizard84
Technical User
Hi,
I am very new to VB Scripts, and hence i already have a question to ask.
The code i have written is probably very innefficient, but what i am trying to do is compare the DateLastModified attributes of a collection of pictures that are in a folder, and then according to the number of days past 11/04/10 (mm/dd/yy), move selected pictures from within the set of total pictures into the respective 'week' folders.
However, i'm not sure if it's due to the wildcards for the MoveFile source location, but it seems that when the program looks at the first picture file, it will move the entire set of photos to the specific week folder. Therefore it seems that even though the For Each...Then statement is used, since there are no more pictures in the set, the script will finish.
Could anyone please shed some light on what the wildcards need to be in order to move pictures to the respective folders individually.
Thanks alot!
--------------------------
dim objFSO, objFolder
dim colFiles, source, misc, value, newdate, olddate
dim week1, week2, week3, week4, week5, week6, week7, week8, week9, week10, week11, week12, week13, week14, week15, week16
source = "C:\Test1\"
destination = "C:\Test\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(source)
Set colFiles = objFolder.Files
week1 = "C:\Test\Week 1"
week2 = "C:\Test\Week 2"
week3 = "C:\Test\Week 3"
week4 = "C:\Test\Week 4"
week5 = "C:\Test\Week 5"
week6 = "C:\Test\Week 6"
week7 = "C:\Test\Week 7"
week8 = "C:\Test\Week 8"
week9 = "C:\Test\Week 9"
week10 = "C:\Test\Week 10"
week11 = "C:\Test\Week 11"
week12 = "C:\Test\Week 12"
week13 = "C:\Test\Week 13"
week14 = "C:\Test\Week 14"
week15 = "C:\Test\Week 15"
week16 = "C:\Test\Week 16"
misc = "C:\Test\Misc"
olddate = #11/04/10#
For Each objFile In colFiles
newdate = objFile.DateLastModified
value = DateDiff("d", olddate, newdate)
If value <= 6 Then
objFSO.MoveFile "C:\Test1\*", week1
elseif value <= 13 Then
objFSO.MoveFile "C:\Test1\", week2
elseif value <= 20 Then
objFSO.MoveFile "C:\Test1\", week3
elseif value <= 27 Then
objFSO.MoveFile "C:\Test1\", week4
elseif value <= 34 Then
objFSO.MoveFile "C:\Test1\", week5
elseif value <= 41 Then
objFSO.MoveFile "C:\Test1\", week6
elseif value <= 48 Then
objFSO.MoveFile "C:\Test1\", week7
elseif value <= 55 Then
objFSO.MoveFile "C:\Test1\", week8
elseif value <= 62 Then
objFSO.MoveFile "C:\Test1\", week9
elseif value <= 69 Then
objFSO.MoveFile "C:\Test1\", week10
elseif value <= 76 Then
objFSO.MoveFile "C:\Test1\", week11
elseif value <= 83 Then
objFSO.MoveFile "C:\Test1\", week12
elseif value <= 90 Then
objFSO.MoveFile "C:\Test1\", week13
elseif value <= 97 Then
objFSO.MoveFile "C:\Test1\", week14
elseif value <= 104 Then
objFSO.MoveFile "C:\Test1\", week15
elseif value <= 111 Then
objFSO.MoveFile "C:\Test1\", week16
else
objFSO.MoveFile "C:\Test1\", misc
end If
Next
I am very new to VB Scripts, and hence i already have a question to ask.
The code i have written is probably very innefficient, but what i am trying to do is compare the DateLastModified attributes of a collection of pictures that are in a folder, and then according to the number of days past 11/04/10 (mm/dd/yy), move selected pictures from within the set of total pictures into the respective 'week' folders.
However, i'm not sure if it's due to the wildcards for the MoveFile source location, but it seems that when the program looks at the first picture file, it will move the entire set of photos to the specific week folder. Therefore it seems that even though the For Each...Then statement is used, since there are no more pictures in the set, the script will finish.
Could anyone please shed some light on what the wildcards need to be in order to move pictures to the respective folders individually.
Thanks alot!
--------------------------
dim objFSO, objFolder
dim colFiles, source, misc, value, newdate, olddate
dim week1, week2, week3, week4, week5, week6, week7, week8, week9, week10, week11, week12, week13, week14, week15, week16
source = "C:\Test1\"
destination = "C:\Test\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(source)
Set colFiles = objFolder.Files
week1 = "C:\Test\Week 1"
week2 = "C:\Test\Week 2"
week3 = "C:\Test\Week 3"
week4 = "C:\Test\Week 4"
week5 = "C:\Test\Week 5"
week6 = "C:\Test\Week 6"
week7 = "C:\Test\Week 7"
week8 = "C:\Test\Week 8"
week9 = "C:\Test\Week 9"
week10 = "C:\Test\Week 10"
week11 = "C:\Test\Week 11"
week12 = "C:\Test\Week 12"
week13 = "C:\Test\Week 13"
week14 = "C:\Test\Week 14"
week15 = "C:\Test\Week 15"
week16 = "C:\Test\Week 16"
misc = "C:\Test\Misc"
olddate = #11/04/10#
For Each objFile In colFiles
newdate = objFile.DateLastModified
value = DateDiff("d", olddate, newdate)
If value <= 6 Then
objFSO.MoveFile "C:\Test1\*", week1
elseif value <= 13 Then
objFSO.MoveFile "C:\Test1\", week2
elseif value <= 20 Then
objFSO.MoveFile "C:\Test1\", week3
elseif value <= 27 Then
objFSO.MoveFile "C:\Test1\", week4
elseif value <= 34 Then
objFSO.MoveFile "C:\Test1\", week5
elseif value <= 41 Then
objFSO.MoveFile "C:\Test1\", week6
elseif value <= 48 Then
objFSO.MoveFile "C:\Test1\", week7
elseif value <= 55 Then
objFSO.MoveFile "C:\Test1\", week8
elseif value <= 62 Then
objFSO.MoveFile "C:\Test1\", week9
elseif value <= 69 Then
objFSO.MoveFile "C:\Test1\", week10
elseif value <= 76 Then
objFSO.MoveFile "C:\Test1\", week11
elseif value <= 83 Then
objFSO.MoveFile "C:\Test1\", week12
elseif value <= 90 Then
objFSO.MoveFile "C:\Test1\", week13
elseif value <= 97 Then
objFSO.MoveFile "C:\Test1\", week14
elseif value <= 104 Then
objFSO.MoveFile "C:\Test1\", week15
elseif value <= 111 Then
objFSO.MoveFile "C:\Test1\", week16
else
objFSO.MoveFile "C:\Test1\", misc
end If
Next