Skip to content

Instantly share code, notes, and snippets.

@slv922
Last active April 27, 2017 09:55
Show Gist options
  • Save slv922/77f9a21b45f58f07d6270badd61e87fd to your computer and use it in GitHub Desktop.
Save slv922/77f9a21b45f58f07d6270badd61e87fd to your computer and use it in GitHub Desktop.
搬移某目錄中的大量檔案到多個目錄並控制每個目錄中的檔案數量
from glob import glob
import os
filelist=glob('MSGS/00/*')
# folder number
for i in range(900):
#os.system("mkdir %03d" %i)
print("mkdir %03d" %i)
#file number in folder
for j in range(10000):
try:
file=filelist.pop(0)
except:
print("file empty, bye!")
exit(0)
#os.system("mv %s %03d" % (file,i))
print("mv %s %03d" % (file,i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment