aandroidtest
aandroidtest

Reputation: 1503

Robocopy based on extensions

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

Answers (1)

MervS
MervS

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

Related Questions