python 移動文件python
利用python寫一些簡單的腳本整理程序,爲生活服務是一個目標code
這個程序就是爲了移動指定文件下的指定類型的文件到目標文件下utf-8
# -*- coding: utf-8 -*- import os import sys import shutil print 'move vedio into the sure folder' # set the file position where to move #須要移動的文件的原路徑 orgin_path = '/Users/wqp/Downloads/' #移動的文件的目標路徑 target_path = '/Users/wqp/Downloads/youtube/' #移動的文件類型 這是個tuple file_type =('.mp4','.rmvb','.MP4','RMVB') for file in os.listdir(orgin_path): if file.endswith(file_type): shutil.move(orgin_path+file,target_path)