Project 010
Project Folder Shortcut.
Visual Basic Script tool to quickly open folders.
Stack
- Visual Basic Script
- Windows OS
- Productivity
Live
—
Source
—
File structures within large organisations can often be cumbersome. This FolderFinder shortcut opens a folder based on a search string of the first 3 letters input by the user.
VB Code
'FOLDER FINDER SCRIPT
Dim jobNumber
Dim tempString
Dim validInput
Dim fileLocation
fileLocation = "REPLACE THIS WITH THE ROOT FILE LOCATION EG: c:companyProjects"
validInput = 0
Do While validInput = 0
validInput = 1
'Get user input and validate
jobNumber = InputBox("Enter Job Number:")
'Quit if Cancel or Escape
If IsEmpty(jobNumber) Then
Wscript.Quit
Else
jobNumber = LCase(jobNumber)
End If
If Len(jobNumber) <> 3 Then
MsgBox "Wrong String Length"
validInput = 0
End If
Loop
'*****while next
'Create Explorer Object
'MsgBox "fileLocation:" & fileLocation
Set WshShell = WScript.CreateObject("WScript.Shell")
'Find Subfolder and Open
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(fileLocation)
For Each objFile in objFolder.SubFolders
'Search for the folder extension using +1 because the extension starts with /
If LCase(Mid(objFile.Path, Len(fileLocation)+1, 3)) = jobNumber Then
'MsgBox Mid(objFile.Path, Len(fileLocation)+1, 3)
'MsgBox "You entered:" & jobNumber
'MsgBox objFile.Path
WshShell.Run "Explorer /n," & Chr(34) & objFile.Path & Chr(34), 1, False
Wscript.Quit
Exit For
End If
Next
MsgBox "Job Folder Does Not Exist!"
WshShell.Run "Explorer /n," & fileLocation, 1, False
'README
'Copy the code into a new notepad file and save-as folderfinder.vbs
'Right-click your desktop -> New -> Shortcut
'In the location field type: (including the quotes)
'C:WindowsSystem32wscript.exe"[FULL PATH TO folderfinder.vbs]"
'Click next
'The new shortcut can be dragged onto the taskbar
'The keyboard shortcut for the taskbar is WINDOWS+[Task bar item]