Skip to content

Instantly share code, notes, and snippets.

@trsqxyz trsqxyz/fileMove.py
Last active Dec 26, 2015

Embed
What would you like to do?
任意の拡張子のファイルを移動する 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
You can’t perform that action at this time.