@@ -0,0 +1,1613 @@
+#!/usr/bin/env python%0A# coding=utf-8%0A# author:andrewallanwallace@gmail.com%0A'''%0AThis simple script is written for easily swap two files or two folders.%0A'''%0A%0A%0Adef swap(origin, dest, temp):%0A    '''%0A    Swap files %0A    mv origin temp%0A    mv dest origin%0A    mv temp dest%0A    '''%0A    from os import system%0A    origin2Temp = 'mv -f -v %25s %25s'%25(origin, temp)%0A    system(origin2Temp)%0A    %0A    dest2Origin = 'mv -f -v %25s %25s'%25(dest, origin)%0A    system(dest2Origin)%0A%0A    temp2Dest = 'mv -f -v %25s %25s'%25(temp, dest)%0A    system(temp2Dest)%0A%0A%0Adef shouldSwap(origin, dest):%0A    from os import path%0A    %0A    originExists = path.exists(origin)%0A    destExists = path.exists(dest)%0A%0A    if(not originExists or not destExists):%0A        print 'Both the files should be existing %25s existing State = %25s ; %25s existing State = %25s'%25(origin, str(originExists), dest, str(destExists))%0A        return False %0A    %0A    originIsDir = path.isdir(origin)%0A    destIsDir = path.isdir(dest)%0A%0A    if (originIsDir != destIsDir):%0A        print 'the two files should be the same type %25s is dir = %25s ;%25s is dir = %25s'%25(origin, str(originIsDir), dest, str(destIsDir))%0A        return False%0A    return True%0A        %0A%0Adef main():%0A    '''%0A    Usage:swapf.py origin dest %5Btemp%5D%0A    '''%0A    import sys%0A    paramsSize = len(sys.argv)%0A    %0A    origin = None%0A    dest = None%0A    temp = 'temp_backup.file'%0A%0A    if (paramsSize %3C 3):%0A        print main.__doc__%0A        return%0A%0A    origin = str(sys.argv%5B1%5D)%0A    dest = str(sys.argv%5B2%5D)%0A%0A%0A    if (paramsSize == 4):%0A        temp = str(sys.argv%5B3%5D)%0A%0A%0A    if (shouldSwap(origin, dest)):%0A        swap(origin, dest, temp)%0A%0A%0A%0Amain()%0A

add swapf.py