Created
February 9, 2015 12:56
-
-
Save nari-ex/4a95aa049ebfe0b2afd1 to your computer and use it in GitHub Desktop.
大量のファイルを移動するスクリプト
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 time | |
src_dir = "" | |
dst_dir = "" | |
import_file = "" | |
export_file = "" | |
if __name__ == '__main__': | |
file_list = open(import_file, 'r') | |
result_file = open(export_file, 'w') | |
for count, line in enumerate(file_list.readlines()): | |
filename = line.lstrip('./').rstrip('\r\n') | |
src_file = os.path.join(src_dir, filename) | |
if not os.path.exists(src_file): | |
result_file.write(line) | |
else: | |
dst_file = os.path.join(dst_dir, filename) | |
if not os.path.exists(dst_file): | |
os.rename(src_file, dst_file) | |
if count % 100 == 0: | |
time.sleep(0.1) | |
result_file.close() | |
file_list.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment