'Copy selected files from one to another location

I want to copy 10 files from one folder to another. In the source folder I have 100 files but I need files from 30-40 only. I have the list of all files.

for i in listi:
    shutil.copy(src,dest)

This copy the entire files, but I need only 10 from no 30 to 40



Solution 1:[1]

Is listi your list of files? How are src and dest defined? As is your code would be copying the same src to dest len(listi) times?

Try for i in listi[30:40] to get files 30-39 inclusive, but you'd need to then do shutil.copy(i, dest) to copy those files.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 goblinshark