Apr-02-2021, 07:01 PM
Current behavior: blinking cursor
Expected behavior: renaming media files.
Steps I took to make this project
1. First I use pathlib to iterate for each file in the current folder.
2. Second I check if the file suffix on capital letters I convert it to
small.
3. Third I check if the file suffix is '.m4v'.
4. Fourth If the file suffix is .m4v I use win32com to get the Media
Creation date and time
5. Fifth I modify the date and time to fit the windows naming system.
6. Finally I use os.rename to rename any file that it's extension equal
.m4v with the t value which is in fifth step.
Everything works but renaming is not!
printing the the original files name works.
printing the media creation date using win32com works fine.
printing random text before the renaming line works.
printing random text after renaming line doesn't work.
here is the code:
Expected behavior: renaming media files.
Steps I took to make this project
1. First I use pathlib to iterate for each file in the current folder.
2. Second I check if the file suffix on capital letters I convert it to
small.
3. Third I check if the file suffix is '.m4v'.
4. Fourth If the file suffix is .m4v I use win32com to get the Media
Creation date and time
5. Fifth I modify the date and time to fit the windows naming system.
6. Finally I use os.rename to rename any file that it's extension equal
.m4v with the t value which is in fifth step.
Everything works but renaming is not!
printing the the original files name works.
printing the media creation date using win32com works fine.
printing random text before the renaming line works.
printing random text after renaming line doesn't work.
here is the code:
```py import os import pathlib from PIL import Image from PIL.ExifTags import TAGS # import datetime from win32com.propsys import propsys, pscon import time from datetime import datetime for p in pathlib.Path.cwd().iterdir(): ext = p.suffix tl = ext.lower() if p.suffix == '.m4v': vid = p.stem + p.suffix properties = propsys.SHGetPropertyStoreFromParsingName(str(p)) dt = properties.GetValue(pscon.PKEY_Media_DateEncoded).GetValue() t = datetime.strftime(dt, '%Y%m%d') print(dt) os.rename(vid , t + p.suffix) mov_name = p.stem ```