Skip to content

Instantly share code, notes, and snippets.

@buildingwatsize
Forked from rehannali/trial-reset.py
Created April 9, 2025 09:23
Show Gist options
  • Save buildingwatsize/681b8cc3dc734ec296f71093db5e238a to your computer and use it in GitHub Desktop.
Save buildingwatsize/681b8cc3dc734ec296f71093db5e238a 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment