forked from mcneel/rhino-developer-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BatchProcessFiles.rvb
58 lines (43 loc) · 1.68 KB
/
BatchProcessFiles.rvb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BatchProcessFiles.rvb -- February 2011
' If this code works, it was written by Dale Fugier.
' If not, I don't know who wrote it.
' Works with Rhino 4.0.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BatchProcessFiles
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub BatchProcessFiles()
Dim sFolder, oFSO, oFolder
' Allow the user to interactively pick a folder
sFolder = Rhino.BrowseForFolder(, "Select folder to process", "Batch Process Files")
If VarType(sFolder) <> vbString Then Exit Sub
' Create a file system object
Set oFSO = CreateObject("Scripting.FileSystemObject")
' Get a folder object based on the selected folder
Set oFolder = oFSO.GetFolder(sFolder)
' Process the folder
Call RecurseFolder(oFolder)
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' RecurseFolder
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub RecurseFolder(oFolder)
Dim oFile, oSubFolder
' Process each file in the folder
For Each oFile In oFolder.Files
Call ProcessFile(oFile.Path)
Next
' Process each subfolder in this folder
'For Each oSubFolder In oFolder.SubFolders
' Call RecurseFolder(oSubFolder)
'Next
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ProcessFile
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ProcessFile(sFile)
' TODO: Add functionality here
Call Rhino.Print(sFile)
End Sub