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
31
32
33
34
35
36
37
38
function! Backup2UsbMemory(dir, compress)
    if a:dir =~ '/$'
       let l:dirroot = a:dir
    else
       let l:dirroot = a:dir .'/'
    endif
    let l:dirname = l:dirroot .strftime("%Y/%Y_%m/%d")
    if isdirectory(l:dirname) == 0
        if isdirectory(l:dirroot .strftime("%Y/%Y_%m")) == 0
            if isdirectory(l:dirroot .strftime("%Y/")) == 0
                call mkdir(l:dirroot .strftime("%Y/"))
            endif
            call mkdir(l:dirroot .strftime("%Y/%Y_%m"))
        endif
        call mkdir(l:dirname)
        if expand('%') == ''
            echo 'Vim only made a directory named "' .l:dirname .'/"'
            return
        endif
    elseif expand('%') == ''
        echohl ErrorMsg
        echo 'Error: No file name'
        echo 'Directory ' .l:dirname ." is already made."
        echohl None
        return
    endif
    let l:compformat = ''
    if a:compress == 'gzip'
        let l:compformat = '.gz'
    elseif a:compress == 'bzip2'
        let l:compformat = '.bz2'
    endif
    let l:extend = expand("%:e")
    if l:extend != ""
        let l:extend = "." .l:extend
    endif
    exec "w" l:dirname .'/'. expand("%:t:r")."_".strftime("%y%m%d_%H%M") .l:extend .l:compformat
endfunction
inserted by FC2 system