Skip to content

Instantly share code, notes, and snippets.

@rehannali
Last active November 3, 2023 08:43
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save rehannali/6b4ba23981f8dcfe124d85599aa8aedc to your computer and use it in GitHub Desktop.
Save rehannali/6b4ba23981f8dcfe124d85599aa8aedc to your computer and use it in GitHub Desktop.
Trial Reseter for MAC
import os
from pathlib import Path
from sys import argv
class ResetTrial:
path = str(Path().home()) + "/Library/"
file_array = []
dir_array = []
def iterate_over_files(self, subString):
for dir_path, sub_dir_path, files in os.walk(self.path):
for file in files:
found = subString in str(file).lower()
if found:
self.file_array.append(str(os.path.join(dir_path, file)))
for direc in sub_dir_path:
found = subString in str(direc).lower()
if found:
self.dir_array.append(str(os.path.join(dir_path, direc)))
self.print_files_dirs()
self.perform_reset_trial()
def perform_reset_trial(self):
print("\n")
print("*" * 40)
alert = """
Are these files/Directories looks good to you? If yes
Enter y or Y to continue : """
value = input(alert)
if value.lower() == "y":
for file in self.file_array:
os.system("rm {}".format(file))
for dirs in self.dir_array:
os.system("rm -rf {}".format(dirs))
print("Successfully reset trial!!!")
def print_files_dirs(self):
print("-" * 10 + " Files " + "-" * 10)
print(*self.file_array, sep="\n")
print("\n")
print("-" * 10 + " Directories " + "-" * 10)
print(*self.dir_array, sep="\n")
if __name__ == "__main__":
print("-" * 40)
alert = """
Always provide valid input, which you want to search for application data and reset trial.
This could delete useful files if you enter wrong input. Use at your own risk.
Provide valid string to reset trial. (Ex. Enter proxifier to reset trial for proxifier)
"""
print(alert)
print("-" * 40)
value = input("Enter y or Y to continue: ")
if value.lower() == "y":
reset_trial = ResetTrial()
string_need_to_found = input("Enter keywork or name of application : ")
if not string_need_to_found.strip():
print("Provide a valid string to search in files and directories")
else:
reset_trial.iterate_over_files(string_need_to_found)
@m4th3r0b0t
Copy link

Brilliant bro, Absolutely live savior.

@GuteriaOnline
Copy link

Brilliant bro, Absolutely live savior.

Hey, guys. I'm completely noob using mac os. Can you please tell how can I run this script? Tried to do it but received a "command not found" message.

Tried to update python using the PKG file but no luck so far.

Thanks in advance.

@sergiycheck
Copy link

sergiycheck commented Oct 20, 2023

Files were removed, but some programs like Viscosity anyway shows trial expired message !

@rehannali
Copy link
Author

Hey @sergiycheck, it's possible that there might be some files in the root directory that need attention. Various software use different locations and to ensure everything is covered, it might take a little extra time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment