I am currently trying to work on a program to automatically copy a PowerPoint into another file when ran however I cannot use shutil as it cannot handle pptx files any suggestions would be appreciated.
Asked
Active
Viewed 80 times
-1
-
Hi and welcome to Stack Overflow. Please [edit](https://stackoverflow.com/posts/52882102/edit) your question to include code you have already tried. – Ruzihm Oct 18 '18 at 20:37
-
What do you mean by “it cannot copy the pptx file”? – Laurent LAPORTE Oct 18 '18 at 20:46
-
I am trying to make a program that can copy a pptx file from one destination to another – J.Rimmer Oct 19 '18 at 18:46
1 Answers
0
Just copying the file?
import os
os.popen('copy .\\file1.txt .\\test\\file1.txt')
If you're trying to move ALL .pptx files in a directory to a backup, something like this might work for a more, hassle-free method:
import os
from os import listdir
from os.path import isfile, join
path = "./"
included_extensions = ['pptx','PPTX']
allFiles = [f for f in listdir(path) if any(f.endswith(ext) for ext in included_extensions)]
length = len(allFiles)
for i in range(length):
os.popen('copy .\\'+allFiles[i]+' .\\backup\\'+allFiles[i])

Mark Cook
- 179
- 1
- 11