EGN <[email protected]> added the comment:
from os import getcwd, listdir, rename
import re
[rename(f'{p}{n}', f"{p}{''.join([w[:3] if len(w) > 3 else w for w in
re.split('[-_. ]', n)[:-1]])}.{n.split('.')[-1]}")
for n in listdir(p := f"{getcwd()}\\{input('Folder: ')}\\")]
When I run this code, I'm getting:
File "C:\Users\1\Desktop\sn.py", line 4
[rename(f'{p}{n}',f"{p}{''.join([w[:3] if len(w)>3 else w for w in
re.split('[-_. ]',n)[:-1]])}.{n.split('.')[-1]}") for n in
listdir(p:=f"{getcwd()}\\{input('Folder: ')}\\")]
^
SyntaxError: assignment expression cannot be used in a comprehension iterable
expression
Process finished with exit code 1
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue38556>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com