Browse Source

Asset file type rename

master
venkataakhil 2 years ago
parent
commit
721e190a4d
  1. 26
      smart_service/apis/master_api.py

26
smart_service/apis/master_api.py

@ -8,8 +8,14 @@ import json
from frappe.utils import cstr from frappe.utils import cstr
import datetime import datetime
from smart_service.apis.app_user_login import input_validation from smart_service.apis.app_user_login import input_validation
import os
current_db_name = frappe.conf.get("db_name") 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) @frappe.whitelist(allow_guest=True)
def masters1(): def masters1():
@ -285,3 +291,23 @@ def masters(args=None, LSD=None):
api = {"status": 0, "error": e} api = {"status": 0, "error": e}
return api 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

Loading…
Cancel
Save