0

I have created folder where i'm copying 3 source files. I want to check files exist in folder or not? if any file is missing from that folder then print the file name and pick that file from archive folder.

Source files name-

File1.xlsx
File2.xlsx
File3.xlsx

Archive name -

source_files.zip

Suppose File2.xlsx is missing in the folder then this file will be pick from archive and copy into that source file folder.

Please help me to implement this logic.

ashmita
  • 39
  • 6
  • Did you try any code? Provide that and we can help you on top of that! – Devesh Kumar Singh Apr 22 '19 at 07:00
  • Possible duplicate of [How do I check whether a file exists without exceptions?](https://stackoverflow.com/questions/82831/how-do-i-check-whether-a-file-exists-without-exceptions) – Alec Apr 22 '19 at 07:08

1 Answers1

0

You're probably best off with a simple try-except statement:

try:
    # Open File
except IOError:
    # Open Archive File

You can find more info here

Alec
  • 8,529
  • 8
  • 37
  • 63