-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencryptScript.ms
More file actions
46 lines (40 loc) · 1.23 KB
/
encryptScript.ms
File metadata and controls
46 lines (40 loc) · 1.23 KB
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
-- Function for replacing backslashes with the given string
function replaceBackslashes inputString replaceString = (
-- VARIABLES
arr = #( )
result = ""
for i = 1 to inputString.count do (
if inputString[i] == "\\" then (
append arr replaceString
) else (
append arr inputString[i]
)
)
for j = 1 to arr.count do (
result += arr[j]
)
return result
)
-- Function for getting the destination folder based on the relative path for the current script
function getDestinationFolder = (
-- Get the current script filepath + filename
scriptFilePath = getThisScriptFilename()
-- Replace backslashes from the path with forward slashes for easier regex replacement
newPath = replaceBackslashes scriptFilePath "/"
rgx = dotnetObject "System.Text.RegularExpressions.Regex" "\/[^/]+$"
result = rgx.Replace newPath "/dist/"
return result
)
-- Main function for encrypting scripts that are located inside the destination folder
function main = (
destinationFolder = getDestinationFolder()
print destinationFolder
-- Get the maxscript files from the destination folder
scripts = getFiles ( destinationFolder + "/*.ms" )
-- Encrypt all scripts
for i = 1 to scripts.count do (
encryptScript scripts[i] ;
)
quitMax #noPrompt
)
main()