Sublime Forum

Python plugin to save a copy of files of certain extension

#1

Dear all,

I’m a new sublime 3 user in Windows. I’m trying to write some python plugins to help me with certain repetitive tasks.

In particular, I was wondering if there is a way to have a python plugin that does the following: copy any files with extension .dmp that are currently open in any of the tabs (I’m using grid mode), to the location C:\temp.

Could somebody tell me how to do that?

Thanks a lot in advance.

0 Likes

#2

It’s about as simple as running this in the console (untested):

import shutil; [shutil.move(v.file_name(), R"C:\temp") for v in window.views() if v.file_name() and v.file_name().endswith(".dmp")]

# alternative
import shutil; [shutil.move(path, R"C:\temp") for path in (v.file_name() for v in window.views()) if path and path.endswith(".dmp")]
0 Likes

#3

That was quick, thanks!

0 Likes