nim语言版。- import os, random, sequtils
-
- const
- source = """D:\gayhub\test\测试a"""
- target = """D:\gayhub\test\测试b"""
- max = 600
-
- var dirs:seq[string] = @[]
-
- for k,p in walkDir(source):
- if k == pcFile:
- dirs.add(p)
-
- randomize()
- shuffle(dirs)
-
- var count = 0
-
- if dirs.len > max:
- if dirs.len mod max > 0:
- count = (dirs.len div max) + 1
- else:
- count = dirs.len div max
- else:
- count = 1
-
-
- var dist = dirs.distribute(count, false)
-
- assert dist.len == count
-
- for i, p in dist:
- var path = target / $(i+1)
- discard existsOrCreateDir(path)
- for f in p:
- moveFile(f,path/extractFilename(f))
复制代码
|