This commit is contained in:
MeeeyoAI
2025-04-21 17:06:40 +08:00
parent 3a6601aedd
commit 5fddb7aed2
3 changed files with 71 additions and 2 deletions
+3 -1
View File
@@ -49,7 +49,8 @@ NODE_CLASS_MAPPINGS = {
"CustomCrop": CustomCrop,
"SaveImagEX": SaveImagEX,
"FileCopyCutNode": FileCopyCutNode,
"FileCopyCutNode": FileCopyCutNode,
"FileDeleteNode": FileDeleteNode,
"FileListAndSuffix": FileListAndSuffix,
"ReadExcelData": ReadExcelData,
"WriteExcelData": WriteExcelData,
@@ -108,6 +109,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"SaveImagEX": "保存图像(meeeyo.com)",
"FileCopyCutNode": "文件操作(meeeyo.com)",
"FileDeleteNode": "清理文件(meeeyo.com)",
"FileListAndSuffix": "从路径加载(meeeyo.com)",
"ReadExcelData": "读取表格数据(meeeyo.com)",
"WriteExcelData": "写入表格数据(meeeyo.com)",
+67
View File
@@ -427,6 +427,73 @@ class FileCopyCutNode:
return (result,)
#======清理文件
class FileDeleteNode:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"target_paths": ("STRING", {"default": "", "multiline": True}),
},
"optional": {
"any": ("*",),
},
}
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("result",)
FUNCTION = "delete_files"
CATEGORY = "Meeeyo/File"
DESCRIPTION = "如需更多帮助或商务需求(For tech and business support)+VX/WeChat: meeeyo"
def delete_files(self, target_paths, **kwargs):
result = "执行失败"
deleted_count = 0
total_count = 0
error_messages = []
try:
# 拆分多行路径并去空
paths = [path.strip() for path in target_paths.split('\n') if path.strip()]
total_count = len(paths)
if total_count == 0:
raise Exception("未提供有效的文件路径")
# 遍历所有路径进行删除
for path in paths:
if not os.path.exists(path):
error_messages.append(f"路径不存在: {path}")
continue
try:
# 删除文件或文件夹
if os.path.isfile(path):
os.remove(path)
else:
shutil.rmtree(path)
deleted_count += 1
except Exception as e:
error_messages.append(f"删除失败: {path} - {str(e)}")
# 构建结果字符串
result_parts = []
if deleted_count > 0:
result_parts.append(f"成功删除 {deleted_count}/{total_count} 个路径")
if error_messages:
result_parts.append("\n错误详情:")
result_parts.extend(error_messages)
result = "\n".join(result_parts)
except Exception as e:
result = f"执行失败: {str(e)}"
return (result,)
#======文件路径和后缀统计
class FileListAndSuffix:
def __init__(self):
+1 -1
View File
@@ -83,7 +83,7 @@ class ReadWebNode:
RETURN_TYPES = ("STRING",)
FUNCTION = "fetch_data"
CATEGORY = "Meyo/Functional"
CATEGORY = "Meeeyo/Functional"
DESCRIPTION = "如需更多帮助或商务需求(For tech and business support)+VX/WeChat: meeeyo"
def IS_CHANGED():