正好最近学python,就动手造了一个轮子:
首先写个nemo-action:
代码: 全选
Exec=<NewFolderWithSelection.py %F>
Quote=double
代码: 全选
import os
import sys
from time import time,localtime,strftime
import shutil
DefPath=strftime("%Y-%m-%d_%H-%M-%S",localtime(time()))
#这里借用了时间标签,防止万一有个同名文件夹,之后移动文件了,好再找回来,大家有什么更好的主意吗?
AllPath=[]
for i in sys.argv[1:]:
AllPath.append(i)
CommonPath=os.path.commonprefix(AllPath)
isExists=os.path.exists(CommonPath)
if not isExists:
pass
else:
CommonPath=os.path.join(CommonPath,DefPath)
os.makedirs(CommonPath)
for i in sys.argv[1:]:
shutil.move(i,CommonPath)