# This script demonstrates how to use the action manager to execute a # previously defined action liek the default actions that ships with Photoshop # Or one that you've created yourself. The name of the action comes from # Photoshop's Actions Palette import os from win32com.client import Dispatch, GetActiveObject, GetObject def getFileList(dir, Filelist, ext=None): """ 获取文件夹及其子文件夹中文件列表 输入 dir:文件夹根目录 输入 ext: 扩展名 返回: 文件路径列表 """ newDir = dir if os.path.isfile(dir): if ext is None: Filelist.append(dir) else: if ext in dir[-3:]: # jpg为-3/py为-2 Filelist.append(dir) elif os.path.isdir(dir): for s in os.listdir(dir): newDir = os.path.join(dir, s) getFileList(newDir, Filelist, ext) return Filelist org_img_folder = r'C:\\Users\\ZG\\Desktop\\' # 检索文件 imglist = getFileList(org_img_folder, [], 'jpg') print('本次执行检索到 ' + str(len(imglist)) + ' 个jpg文件\n') print(len(imglist)) if len(imglist): try: app = GetActiveObject("Photoshop.Application") except: app = Dispatch("Photoshop.Application") fileName = "C:\\Users\ZG\\Desktop\\il_fullxfull.2415706261_ez81.jpg" docRef = app.Open(fileName) for imgpath in imglist: imgname = os.path.splitext(os.path.basename(imgpath))[0] print(imgpath) docRef = app.Open(imgpath) app.DoAction('熔化的铅块', '默认动作')
windows python 打开 ps调用动作批量自动化处理本地图片
最新推荐文章于 2024-10-16 11:12:16 发布