Aug-06-2020, 02:06 PM
Hi,
This is my first post so really sorry if I have done this incorrectly.
I have added raw_input that lets the user choose file extension.
The next criteria I am looking to add is a date range so they can choose a date range for example:
17/07/2020 to 04/08/2020 or Today() like in excel
example on terminal
file extension = .csv
startdate = 12/05/2020
enddate = 07/08/2020
once the user has input these fields it would copy only the required files over.
The current output of the created files are:
[+] File transferred BASE1011.xls last modified: Fri Jul 17 10:11:40 2020
[+] File transferred BASE1112.xls last modified: Fri Jul 17 10:11:40 2020
[+] File transferred BASE1213.xls last modified: Fri Jul 17 10:11:40 2020
[+] File transferred BASE1314.xls last modified: Fri Jul 17 10:11:40 2020
[+] File transferred BASE1415.xls last modified: Fri Jul 17 10:11:40 2020
I want these to be in an easier format for user input as explained above:
example: start 12/05/2020 end date = 07/08/2020
Thank you for your help, I am not the best at python so really sorry about poor coding but I am trying to learn so any help would be amazing.
Thanks
This is my first post so really sorry if I have done this incorrectly.
I have added raw_input that lets the user choose file extension.
The next criteria I am looking to add is a date range so they can choose a date range for example:
17/07/2020 to 04/08/2020 or Today() like in excel
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import os import shutil import os.path, time from pip._vendor.distlib.compat import raw_input src = ("") dst = ("") ext = raw_input ( "[+] File format: " ) created = ( " last modified: %s" % time.ctime(os.path.getmtime(src))) start = raw_input ( "[+] Date start: " ) end = raw_input ( "[+] Date end: " ) for filename in os.listdir(src): if filename.endswith( '.' + ext) and created.startswith(start) and created.endswith(end): shutil.copy( src + filename, dst) print ( "[+] File transferred " + filename + created) |
file extension = .csv
startdate = 12/05/2020
enddate = 07/08/2020
once the user has input these fields it would copy only the required files over.
The current output of the created files are:
[+] File transferred BASE1011.xls last modified: Fri Jul 17 10:11:40 2020
[+] File transferred BASE1112.xls last modified: Fri Jul 17 10:11:40 2020
[+] File transferred BASE1213.xls last modified: Fri Jul 17 10:11:40 2020
[+] File transferred BASE1314.xls last modified: Fri Jul 17 10:11:40 2020
[+] File transferred BASE1415.xls last modified: Fri Jul 17 10:11:40 2020
I want these to be in an easier format for user input as explained above:
example: start 12/05/2020 end date = 07/08/2020
Thank you for your help, I am not the best at python so really sorry about poor coding but I am trying to learn so any help would be amazing.
Thanks