summaryrefslogtreecommitdiff
path: root/fs/commands/fsmv.py
blob: 9e96de6039c9d5bdc3a162468a33c4f6b0feb309 (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
26
27
28
29
30
#!/usr/bin/env python

from fs.utils import movefile, movefile_non_atomic, contains_files
from fs.commands import fscp
import sys

class FSmv(fscp.FScp):
    
    usage = """fsmv [OPTION]... [SOURCE] [DESTINATION]
Move files from SOURCE to DESTINATION"""
    
    def get_verb(self):
        return 'moving...'
    
    def get_action(self):  
        if self.options.threads > 1:      
            return movefile_non_atomic
        else:
            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 FSmv().run()
    
if __name__ == "__main__":
    sys.exit(run())