Last active
December 26, 2015 00:39
-
-
Save trsqxyz/7066105 to your computer and use it in GitHub Desktop.
任意の拡張子のファイルを移動する
move file of select suffix
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
# -*- coding: utf-8 -*- | |
import os | |
import shutil | |
#src -> dst | |
src = u'/Users/name/Downloads/' | |
dst = {'.jpg': u'/Users/name/Library/jpg/', | |
} | |
for suffix, path in dst.items(): | |
files = os.listdir(src) | |
fL = [f for f in files if suffix in f] #select file | |
sL = [src + sf for sf in fL] #set path | |
dL = [path + df for df in fL] | |
for (s,d) in zip(sL,dL): | |
shutil.move(s,d) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment