Created
June 18, 2013 15:36
-
-
Save cloverrose/5806411 to your computer and use it in GitHub Desktop.
gitのfilter-branchとかで使ったスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
import os.path | |
import shutil | |
def main(source, target): | |
print('\n\n[INFO] start copy {0} to {1}'.format(source, target)) | |
if os.path.isfile(target): | |
try: | |
shutil.copyfile(source, target) | |
except Exception as e: | |
print('[ERROR] {0}'.format(str(e))) | |
exit(0) | |
if __name__ == '__main__': | |
import sys | |
source = sys.argv[1] | |
target = sys.argv[2] | |
print('\n[INFO] source file is {0}'.format(source)) | |
print('\n[INFO] target file is {0}'.format(target)) | |
main(source, target) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
import os | |
import shutil | |
def main(target): | |
print('\n\n[INFO] start move all files into {0}'.format(target)) | |
print('\n[INFO] make dir {0}'.format(target)) | |
try: | |
os.mkdir(target) | |
except Exception as e: | |
print('[ERROR] {0}'.format(str(e))) | |
exit(0) | |
for i in os.listdir("."): # リポジトリのファイルを取得 | |
print('\n[INFO] move {0} into {1}'.format(i, target)) | |
try: | |
shutil.move(i, target) | |
except Exception as e: | |
print('\n\n[ERROR] {0}'.format(str(e))) | |
exit(0) | |
if __name__ == '__main__': | |
import sys | |
target = sys.argv[1] | |
print('\n[INFO] target directory is {0}'.format(target)) | |
main(target) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment