move.py 575 B

123456789101112131415161718192021222324
  1. import os
  2. import sys
  3. import process_command_files as pcf
  4. # /script/move.py <src-1> <tgt-1> <src-2> <tgt-2> ... <src-n> <tgt-n>
  5. # renames src-1 to tgt-1, src-2 to tgt-2, ..., src-n to tgt-n.
  6. def main():
  7. args = pcf.get_args(sys.argv[1:])
  8. assert len(args) % 2 == 0, (len(args), args)
  9. copied = set()
  10. for index in range(0, len(args), 2):
  11. assert args[index] not in copied, "Double input detected for file: {}".format(args[index])
  12. os.rename(args[index], args[index + 1])
  13. copied.add(args[index])
  14. if __name__ == '__main__':
  15. main()