惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tailwind CSS Blog
博客园 - 【当耐特】
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - Franky
小众软件
小众软件
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 三生石上(FineUI控件)
B
Blog
有赞技术团队
有赞技术团队
J
Java Code Geeks
云风的 BLOG
云风的 BLOG
Recent Announcements
Recent Announcements
Jina AI
Jina AI
Vercel News
Vercel News
博客园 - 叶小钗
Hugging Face - Blog
Hugging Face - Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
F
Fortinet All Blogs
The Cloudflare Blog
V
V2EX
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园_首页
腾讯CDC

博客园 - 高天蒲

前端 mysql常见问题 互联网数据的挖掘和分析 针对wordpress的二次开发 datejs lib awk Optimal Logging PHP笔记 grep 笔记 svn笔记 网页内容爬取:如何提取正文内容 快速开发的要素 Javascript 类、命名空间、代码组织 武士与黑客 ImageMagick Errors: Convert PDF to Images web.py学习随笔 HTML5 and CSS3 做前端的一些小工具 提高勾搭的成功几率(瞎写的,打扰了)
python 复制文件
高天蒲 · 2013-05-24 · via 博客园 - 高天蒲
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
source_root = 'D:\source'
test_root = 'D:\target'
files_list = 'files.txt'


def main():
    with open(files_list,'r') as f:
        for l in f:
            tmp = l.strip().replace('/commbook/trunk/commbook','')
            tmp = tmp.replace('/','\\')
            s = source_root + tmp
            t = test_root + tmp
            mkdir(t)
            print 'copy "'+ s +'" "'+ t +'"'
            os.system('copy "'+ s +'" "'+ t +'"')

    return 0

def mkdir(filename):
    segs = filename.split('\\')
    count = len(segs)
    for i in range(2,count):
        p = '\\'.join(segs[:i])
        if(not os.path.exists(p)):
            os.system('mkdir "'+ p +'"')


if __name__ == '__main__':
    main()

posted @ 2013-05-24 15:56  高天蒲  阅读(259)  评论()    收藏  举报