Skip to content

Instantly share code, notes, and snippets.

@trsqxyz
Last active December 26, 2015 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trsqxyz/7066105 to your computer and use it in GitHub Desktop.
Save trsqxyz/7066105 to your computer and use it in GitHub Desktop.
任意の拡張子のファイルを移動する move file of select suffix
# -*- 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