OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How can I modify this script to select any folders dated in the last 12 months?

  • Thread starter Thread starter George Bunkall
  • Start date Start date
G

George Bunkall

Guest
I have a folder directory (shown below) that contains folders titled "year-month." They will be continuously added over time. I am trying to write a python code that selects any files in folders dated in the last 12 months.

enter image description here

I've built code to always select the files in the current year-month folder and it works. If I ran this i'd get all the files in the 2024-06 folder since that is the current month and year. How can I modify this script to grab every folder from the last 12 months?

Code:
today = datetime.datetime.now()
year = today.strftime("%Y")
month=today.strftime("%m")
day=today.strftime("%d")
output = r"'F:\\6 - Business Units\\Sun Pacific Farming Cooperative\\B - General\\17 - GIS\\Drone Imagery\\RBG\\Monthly\\" + year +"-" + month + "\\'"
<p>I have a folder directory (shown below) that contains folders titled "year-month." They will be continuously added over time. I am trying to write a python code that selects any files in folders dated in the last 12 months.</p>
<p><a href="https://i.sstatic.net/AJLxcQW8.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/AJLxcQW8.png" alt="enter image description here" /></a></p>
<p>I've built code to always select the files in the current year-month folder and it works. If I ran this i'd get all the files in the 2024-06 folder since that is the current month and year. How can I modify this script to grab every folder from the last 12 months?</p>
<pre><code>today = datetime.datetime.now()
year = today.strftime("%Y")
month=today.strftime("%m")
day=today.strftime("%d")
output = r"'F:\\6 - Business Units\\Sun Pacific Farming Cooperative\\B - General\\17 - GIS\\Drone Imagery\\RBG\\Monthly\\" + year +"-" + month + "\\'"
</code></pre>
 

Latest posts

Online statistics

Members online
1
Guests online
5
Total visitors
6
Top