Skip to content

Instantly share code, notes, and snippets.

@snydergd
Created March 21, 2016 03:19
Show Gist options
  • Save snydergd/362177cd55bdae30c648 to your computer and use it in GitHub Desktop.
Save snydergd/362177cd55bdae30c648 to your computer and use it in GitHub Desktop.
' If you've copied certain files from folder A to folder B
' And wanted to move them instead
' You can use this to remove files in B from A
' On windows just double click this script and you'll be prompted for folders
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim folderObj, arcFolder, cleanFolder, fileObj, filename
arcFolder = getFolderPath("Archive folder")
cleanFolder = getFolderPath("Folder to clean up")
If (arcFolder = "" or cleanFolder = "") Then
MsgBox("Need both folders. Doing nothing")
WScript.Quit
End If
Set folderObj = fso.GetFolder(cleanFolder)
For each path in folderObj.files
Set fileObj = fso.GetFile(path)
filename = fso.GetFileName(fileObj)
If (fso.FileExists(arcFolder & "\" & filename)) Then
fso.DeleteFile(path)
End If
Next
Function getFolderPath(title)
Dim shell, file
Set shell = CreateObject("Shell.Application")
Set file = shell.BrowseForFolder(0, title, &H4010)
If (file Is Nothing) Then
getFolderPath = ""
Else
getFolderPath = file.self.Path
End If
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment