We're not mind-readers, how do you expect us to know what you tried if you don't tell us?
The walrus operator works for me:
>>> [spam for c in "hello world" if (spam:=c.upper()) in 'AEIOU']
['E', 'O', 'O']
>>> [(spam:=x**2, spam+1) for x in range(5)]
[(0, 1), (1, 2), (4, 5), (9, 10), (16, 17)]
What did you try, and what happened?
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:Users1Desktopsn.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