先实现类似这样的功能
新建个文件夹名称比如叫[xxx][AAA][BBB]
自动执行某脚本,比如:z.py
, 该脚本以这个文件夹名作为入参,解析文件名,然后在这个文件夹下干一些活,比如按照解析的内容生成个文档.
请问,要实现以上两点 (1) 触发脚本 (2)文件名作为入参.
有什么方式么? 我看mac上有个键盘大师软件,可能可以干这个. windows下和linux下有类似的东西么?
update 20161018: 多谢各位,已实现,找到了python跨平台的模块 watchdog , 非常不错. 可以监控路径下的各种文件事件(包括增删改等).
Inotify can be used under Linux (the python package is pyinotify), which can monitor a certain file directory. When a new file or directory is created in the directory, the registered function will be called, and the parameters include file names and other information.
In fact, you can use or write a scaffolding tool directly, such as various web frameworks that automatically generate subdirectories, configuration files, entry files, etc. when creating new projects.
Write an executable bash script called mkdir, and then put the path at the front in PATH