Skip to content

Instantly share code, notes, and snippets.

@bugparty
Created January 21, 2015 09:16
Show Gist options
  • Save bugparty/61af8f9fd94d2afb257f to your computer and use it in GitHub Desktop.
Save bugparty/61af8f9fd94d2afb257f to your computer and use it in GitHub Desktop.
从目录内搜集wmv文件并移动到根目录的脚本
import os
import shutil
cw = os.getcwd()
things =os.listdir(cw)
for thing in things:
filepath = os.path.join(cw,thing)
if os.path.isdir(filepath):
files = os.listdir(filepath)
for file in files:
if file.endswith('.wmv'):
shutil.move(os.path.join(filepath, file),
os.path.join(cw,file))
print 'moving from'+os.path.join(filepath, file)+'to' + os.path.join(cw,file)
#filepath = filepath.decode('gbk')
os.removedirs(filepath)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment