hans

hans

【Python】【Shell】把txt文档中文件名对应的文件cp到其他文件夹


cat file.txt | xargs -i cp {} /path/

txt 中一个文件名占一行

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 13 16:55:14 2017

@author: hans
"""
import Image

f = open('list.txt')
for line in f:
    line=line.strip('\n')
    im = Image.open('/path/to/image/%s' %line)
    im.save('./path/to/destination/%s' %line)
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.