summaryrefslogtreecommitdiff
path: root/fs/commands/fsmv.py
blob: 2de4a4a210f2934bf1721942df91cecc80cd572d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from fs.utils import movefile, contains_files
from fs.commands import fscp
import sys

class FSMove(fscp.FScp):
    
    usage = """fsmv [OPTION]... [SOURCE] [DESTINATION]
Move files from SOURCE to DESTINATION"""
    
    def get_verb(self):
        return 'moving...'
    
    def get_action(self):        
        return movefile
    
    def post_actions(self):
        for fs, dirpath in self.root_dirs:
            if not contains_files(fs, dirpath):                
                fs.removedir(dirpath, force=True)
    
def run():
    return FSMove().run()
    
if __name__ == "__main__":
    sys.exit(run())