diff --git a/smart_service/apis/master_api.py b/smart_service/apis/master_api.py index 9f1b5be..100e326 100644 --- a/smart_service/apis/master_api.py +++ b/smart_service/apis/master_api.py @@ -8,8 +8,14 @@ import json from frappe.utils import cstr import datetime from smart_service.apis.app_user_login import input_validation +import os current_db_name = frappe.conf.get("db_name") +site_name = cstr(frappe.local.site) + +base_url = os.path.expanduser( + "~") + "/frappe-bench/sites/" + site_name + "/public/files" + @frappe.whitelist(allow_guest=True) def masters1(): @@ -285,3 +291,23 @@ def masters(args=None, LSD=None): api = {"status": 0, "error": e} return api + + +def change_file_type(): + folder_path = base_url + count = 0 + for root, dirs, files in os.walk(folder_path): + for file in files: + if file.split('.')[-1] == 'PNG': + count += 1 + f1 = os.path.join(root, file) + f2 = f1[:-3] + 'png' + os.rename(f1, f2) + + if file.split('.')[-1] == 'JPG': + count += 1 + f1 = os.path.join(root, file) + f2 = f1[:-3] + 'jpg' + os.rename(f1, f2) + + return count