Whatever is assigned to the files
variable is incorrect. Use the following code.
import glob
import os
list_of_files = glob.glob('/path/to/folder/*') # * means all if need specific format then *.csv
latest_file = max(list_of_files, key=os.path.getctime)
print(latest_file)
More Related Contents:
- How to match a string to pattern “Foo-Bar”, where Bar can be any element of a list? [closed]
- Searching for IP addresses in a file
- How to remove English words from a file containing Dari words?
- How can I read inputs as numbers?
- Behavior of exec function in Python 2 and Python 3
- Why is a list comprehension so much faster than appending to a list?
- How to print a string at a fixed width?
- How to use pip with Python 3.x alongside Python 2.x
- Why is parenthesis in print voluntary in Python 2.7?
- How can I make a for-loop pyramid more concise in Python? [duplicate]
- How to extract text from an existing docx file using python-docx
- Getting only element from a single-element list in Python?
- Why does this not work as an array membership test? [duplicate]
- Accessing attributes on literals work on all types, but not `int`; why? [duplicate]
- Using multiple Python engines (32Bit/64bit and 2.7/3.5)
- How can I convert 24 hour time to 12 hour time?
- Python regex for unicode capitalized words
- ImportError on python 3, worked fine on python 2.7
- How to get Windows short file name in python?
- What does the “yield” keyword do in Python?
- How to create a Python dictionary with double quotes as default quote format?
- Python 3 urllib produces TypeError: POST data should be bytes or an iterable of bytes. It cannot be of type str
- Multiple keys per value
- WinError 2 The system cannot find the file specified (Python)
- Type error Unhashable type:set
- Loading text file containing both float and string using numpy.loadtxt
- What is absolute import in python?
- Run process with realtime output to a Tkinter GUI
- What does the slice() function do in Python?
- Skip elements on a condition based in a list comprehension in python