move.py 742 B

123456789101112131415161718192021222324252627
  1. import os
  2. import sys
  3. # Explicitly enable local imports
  4. # Don't forget to add imported scripts to inputs of the calling command!
  5. sys.path.append(os.path.dirname(os.path.abspath(__file__)))
  6. import process_command_files as pcf
  7. # /script/move.py <src-1> <tgt-1> <src-2> <tgt-2> ... <src-n> <tgt-n>
  8. # renames src-1 to tgt-1, src-2 to tgt-2, ..., src-n to tgt-n.
  9. def main():
  10. args = pcf.get_args(sys.argv[1:])
  11. assert len(args) % 2 == 0, (len(args), args)
  12. copied = set()
  13. for index in range(0, len(args), 2):
  14. assert args[index] not in copied, "Double input detected for file: {}".format(args[index])
  15. os.rename(args[index], args[index + 1])
  16. copied.add(args[index])
  17. if __name__ == '__main__':
  18. main()