CardReaderDrive = "Z:\" TargetDirectory = "C:\photos\" BackupDirectory = "D:\Photos\" WipeCardWhenDone = "Yes" FileTypes = "crw,cr2,jpg,mp4" x=0 FilesToMove=split(FileTypes,",") Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(CardReaderDrive) 'Wscript.Echo objFolder.Path Set colFiles = objFolder.Files For Each objFile in colFiles FileType=UCASE(right(objFile.Path,3)) for i=0 to uBound(FilesToMove) if FileType=UCASE(FilesToMove(i)) then x=x+1 End If Next Next CountSubfolders objFSO.GetFolder(CardReaderDrive) Total=x if Total=0 then wscript.echo "No files found. Backing up and exiting." BackupCard wscript.quit End If x=1 Set objFolder = objFSO.GetFolder(CardReaderDrive) 'Wscript.Echo objFolder.Path Set colFiles = objFolder.Files For Each objFile in colFiles FileType=UCASE(right(objFile.Path,3)) for i=0 to uBound(FilesToMove) if FileType=UCASE(FilesToMove(i)) then 'Let's parse out the date and make it an array tmpDate=split(objFile.DateLastModified," ") DateElements=Split(tmpDate(0),"/") FileYear=DateElements(2) FileDate=trim(dateElements(1)) FileMonth=trim(DateElements(0)) if len(FileDate)=1 then FileDate="0" & FileDate end if if len(FileMonth)=1 then FileMonth="0" & FileMonth end if TargetDir=TargetDirectory & FileYear & FileMonth & FileDate & "\" if not objFSO.FolderExists(TargetDir) then objFSO.CreateFolder(TargetDir) wscript.echo X & "/" & Total & ": Create " & TargetDir End If wscript.echo X & "/" & Total & ": " & objfile.Name & " -> " & TargetDir on error resume next objfile.Move(TargetDir) x=x+1 End If Next Next ShowSubfolders objFSO.GetFolder(CardReaderDrive) 'nuke routine set objFolders=objfso.GetFolder(CardReaderDrive) if WipeCardWhenDone="Yes" then Recurse objFolders End If 'Backup BackupCard wscript.quit sub BackupCard Set wshShell = WScript.CreateObject ("WSCript.shell") wscript.echo "---Backing up files to " & BackupDirectory Set objExec=wshShell.Exec("xcopy " & TargetDirectory & "* " & BackupDirectory & " /s/e/c/d/y") x=0 Do While objExec.StdOut.AtEndOfStream <> True if instr(objExec.StdOut.Readline,"\")>0 then x=x+1 Loop wscript.echo "---" & x & " files backed up to " & backupDirectory End Sub Sub recurse(ByRef objFolders) Set objSubFolders = objFolders.SubFolders Set objFiles = objFolders.Files for each File in objFiles On Error Resume Next File.Delete Next for each Folder in objSubFolders Recurse Folder Next Set objSubFolders = Nothing Set objFiles = Nothing end Sub Sub ShowSubFolders(Folder) For Each Subfolder in Folder.SubFolders 'Wscript.Echo Subfolder.Path Set objFolder = objFSO.GetFolder(Subfolder.Path) Set colFiles = objFolder.Files For Each objFile in colFiles FileType=UCASE(right(objFile.Path,3)) for i=0 to uBound(FilesToMove) if FileType=UCASE(FilesToMove(i)) then 'Let's parse out the date and make it an array tmpDate=split(objFile.DateLastModified," ") DateElements=Split(tmpDate(0),"/") FileYear=DateElements(2) FileDate=trim(dateElements(1)) FileMonth=trim(DateElements(0)) if len(FileDate)=1 then FileDate="0" & FileDate end if if len(FileMonth)=1 then FileMonth="0" & FileMonth end if TargetDir=TargetDirectory & FileYear & FileMonth & FileDate & "\" if not objFSO.FolderExists(TargetDir) then objFSO.CreateFolder(TargetDir) wscript.echo X & "/" & Total & ": Create " & TargetDir End If wscript.echo X & "/" & Total & ": " & objfile.Name & " -> " & TargetDir on error resume next objfile.Move(TargetDir) x=x+1 End If Next Next ShowSubFolders Subfolder Next End Sub Sub CountSubFolders(Folder) For Each Subfolder in Folder.SubFolders 'Wscript.Echo Subfolder.Path Set objFolder = objFSO.GetFolder(Subfolder.Path) Set colFiles = objFolder.Files For Each objFile in colFiles FileType=UCASE(right(objFile.Path,3)) for i=0 to uBound(FilesToMove) if FileType=UCASE(FilesToMove(i)) then x=x+1 End If Next Next CountSubFolders Subfolder Next End Sub