Skip to content

Instantly share code, notes, and snippets.

@cloverrose
Created June 18, 2013 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cloverrose/5806411 to your computer and use it in GitHub Desktop.
Save cloverrose/5806411 to your computer and use it in GitHub Desktop.
gitのfilter-branchとかで使ったスクリプト
#!/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)
#!/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