Hi together,
I have been learning Python for just 2 months. So basicially I am still a beginner.
However, I am already trying to automate one of my working streams.
For this automiziation I need to copy paste excel files from one path to another path, whereas the "source" path is always a bit different and also the file name within the respective source path is always a bit different (only the first letters of the file names are identical).
E.g:
Files I would like to copy (when I enter "Q4"):
C:\Reports\Oct 23\19) Volumes 1423423_1323.xlsx
C:\Reports\Nov 23\19) Volumes 21313_323.xlsx
C:\Reports\Dec 23\19) Volumes 23434_2132.xlsx
Destination:
C:\Calculation\Q4
My idea is to create 4 lists, when input is e.g. Q4 then go through the Q4 list using it for the source path.
How can I implement it?
Then secondly I would like to say when the first letters of the file name is "19)" then copy it.
By they in the source path there are also hundred other files.
Here is my current working status:
I have been learning Python for just 2 months. So basicially I am still a beginner.
However, I am already trying to automate one of my working streams.
For this automiziation I need to copy paste excel files from one path to another path, whereas the "source" path is always a bit different and also the file name within the respective source path is always a bit different (only the first letters of the file names are identical).
E.g:
Files I would like to copy (when I enter "Q4"):
C:\Reports\Oct 23\19) Volumes 1423423_1323.xlsx
C:\Reports\Nov 23\19) Volumes 21313_323.xlsx
C:\Reports\Dec 23\19) Volumes 23434_2132.xlsx
Destination:
C:\Calculation\Q4
My idea is to create 4 lists, when input is e.g. Q4 then go through the Q4 list using it for the source path.
How can I implement it?
Then secondly I would like to say when the first letters of the file name is "19)" then copy it.
By they in the source path there are also hundred other files.
Here is my current working status:
import shutil Q1 = ["Jan", "Feb", "Mar"] Q2 = ["Apr", "May", "Jun"] Q3 = ["Jul", "Aug", "Sep"] Q4 = ["Oct", "Nov", "Dec"] print("Which quarter do you want to pull?") quarter_input = input("Please enter the quarter Q1, Q2, Q3 or Q4: ") if quarter_input == str("Q4"): for x in Q4: file_to_copy = fr"C:\Reports\{x} 23\19) Volumes 1423423_1323.xlsx" destination_directory = fr"C:\Calculation\19) Volumes 1423423_1323.xlsx" shutil.copy(file_to_copy, destination_directory)