티스토리 뷰

Python

[Python] 파일 수정 시간 받아오기

developer0hye 2022. 1. 7. 21:53
import os.path, time
print("last modified: %s" % time.ctime(os.path.getmtime(file)))
print("created: %s" % time.ctime(os.path.getctime(file))

https://stackoverflow.com/questions/237079/how-to-get-file-creation-modification-date-times

 

How to get file creation & modification date/times?

I have a script that needs to do some stuff based on file creation & modification dates but has to run on Linux & Windows. What's the best cross-platform way to get file creation &

stackoverflow.com

 

yyyy-mm-dd hh:mm:ss 형식으로 받고 싶다면

def get_modified_time(file):
    return datetime.fromtimestamp(os.path.getmtime(file)).strftime('%Y-%m-%d %H:%M:%S')

 

https://stackoverflow.com/questions/19501711/how-can-i-convert-os-path-getctime

 

How can I convert os.path.getctime()?

How can I convert os.path.getctime() to the right time? My source code is: import os print("My Path: "+os.getcwd()) print(os.listdir(".")) print("Root/: ",os.listdir...

stackoverflow.com

 

 

배포했던 패키지에 달린 아래의 이슈 때문에 해당 기능을 찾게 됐었음.

 

https://github.com/developer0hye/BatchedFFmpeg/issues/3

 

FR: keep the file creation date the same as the input file · Issue #3 · developer0hye/BatchedFFmpeg

I have a bunch of home videos in .avi and .mov format I want to all convert to mp4. However, trying a batch ffmpeg caused all the new .mp4 files to have the file creation date of today. Ideally I w...

github.com

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/01   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함