Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. display dialog "Choose where your file is located."
  2. set directory to POSIX path of (choose folder with prompt "File Location:" default location (path to desktop))
  3. display dialog "Choose your file."
  4. set filepath to (choose file with prompt "File Name:")
  5.  
  6. tell application "Finder" to set {dispName, nameExt, isHidden} to ¬
  7.     the {displayed name, name extension, extension hidden} of the filepath
  8.  
  9. tell application "Finder" to set filename to ¬
  10.     the {displayed name} of the filepath
  11.  
  12. if isHidden or nameExt is equal to "" then
  13.     dispName
  14. else
  15.     (characters 1 through (-2 - (count of nameExt)) of dispName) as text
  16. end if
  17.  
  18. set filenameNoEXT to result
  19. set encryptedFileName to text returned of (display dialog "Encrypted File Name:" default answer filenameNoEXT & "_" & "encrypted" & ".zip")
  20.  
  21. if (encryptedFileName ends with ".zip") then
  22.     set pass to text returned of (display dialog "Password:" default answer "" with hidden answer)
  23.     set passC to text returned of (display dialog "Confirm Password:" default answer "" with hidden answer)
  24.     if pass = passC then
  25.         set deleteQ to display dialog "Do you want to remove the original file?" buttons {"Yes", "No"} default button 2
  26.         set answer to button returned of deleteQ
  27.         if answer is equal to "Yes" then
  28.             do shell script "cd " & directory & ";" & "zip -re -P " & "'" & pass & "'" & " " & encryptedFileName & " " & filename & ";" & " rm -r " & filename
  29.         else if answer is equal to "No" then
  30.             do shell script "cd " & directory & ";" & "zip -re -P " & "'" & pass & "'" & " " & encryptedFileName & " " & filename
  31.         end if
  32.     else
  33.         display dialog "Passwords did not match." with icon stop
  34.     end if
  35. else
  36.     display dialog "Encrypted File Name did not end with '.zip'." with icon stop
  37. end if
  38.  
  39. -- Made By Dv3v
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement