简体   繁体   English

仅复制目录中的文件,而不复制目录

[英]Copy only the files within a Directory and not the Directory

I'm trying to copy images in a directory using Python 2.7.12. 我正在尝试使用Python 2.7.12复制目录中的图像。 The problem is that I want to only move the files within the Directory and not the Directory. 问题是我只想移动目录中的文件,而不要移动目录中的文件。 So in bash it would look something like 所以在bash中看起来像

    cp /path/to/source/* . /path/to/destination

but I want to do this in Python 2.7.12. 但是我想在Python 2.7.12中做到这一点。 I know how to copy the directory using things like shutil.copy but you can't add the /* to move the files within the directory. 我知道如何使用shutil.copy之类的东西来复制目录,但是您不能添加/ *在目录中移动文件。 I'm kind of new to python and Stack Overflow so I'm sorry if there is any errors or confusion. 我是python和Stack Overflow的新手,如果有任何错误或混乱,我们深表歉意。

You could just use cmd terminal if your a windows user. 如果您是Windows用户,则只能使用cmd终端。 Type in help Robocopy and it should display different options 输入帮助Robocopy,它应该显示不同的选项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM