将 shell 脚本 (/bin/bash) 添加到自动化工作流(复制文件路径)我想用它从正在复制到剪贴板的变量路径中去除常量前缀“/Volumes/”。
EG 复制文件路径工作流将“/Volumes/GRAID/audiovideo.mov”复制到剪贴板,我希望粘贴的路径是“GRAID/audiovideo.mov”
我有许多带有孩子“名称”的“根”标签。我想对“根”块进行排序,并按“名称”元素按字母顺序排序。尝试过lxml / etree / minidom,但是无法正常工作...我无法获取它来解析标记内的值,然后对父根标记进行排序。
<?xml version='1.0' encoding='UTF-8'?>
<roots>
<root>
<path>//1.1.1.100/Alex</path>
<name>Alex Space</name>
</root>
<root>
<path>//1.1.1.101/Steve</path>
<name>Steve Space</name>
</root>
<root>
<path>//1.1.1.150/Bethany</path>
<name>Bethanys</name>
</root>
</roots>
Run Code Online (Sandbox Code Playgroud)
这是我尝试过的:
import xml.etree.ElementTree as ET
def sortchildrenby(parent, child):
parent[:] = sorted(parent, key=lambda child: child)
tree = ET.parse('data.xml')
root = tree.getroot()
sortchildrenby(root, 'name')
for child in root:
sortchildrenby(child, 'name')
tree.write('output.xml')
Run Code Online (Sandbox Code Playgroud)