Reputation: 1503
Currently I am using robocopy in python to copy out files based on extensions.
The code is below:
call(["robocopy","C:\",dest,"*.7z","/S","/COPYALL"])
But in a scenario where there is no 7z files, it still creates the dest directory.
Is there a way to only create the directory and copy the file only if it exists?
Upvotes: 0
Views: 181
Reputation: 5902
Why not check if there are 7z files before calling the copy utility?
import glob
if glob.glob("*.7z"):
call(["robocopy","C:\",dest,"*.7z","/S","/COPYALL"])
Upvotes: 1