Python Forum
os.rename Windows remove illegal char
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
os.rename Windows remove illegal char
#2
You can use regex substitute method to replace

illegal = ['NUL','\',''//',':','*','"','<','>','|']
 
for i in illegal:
    ctitle = ctitle.replace(i, '')
import re
ctitle = re.sub(r'[\\/\:*"<>\|\.%\$\^&£]', '', ctitle)
Reply


Messages In This Thread
os.rename Windows remove illegal char - by fgerrata - Jan-03-2018, 02:06 PM
RE: os.rename Windows remove illegal char - by hshivaraj - Jan-03-2018, 03:04 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  expecting value: line 1 column 1 (char 0) in print (r.json)) loutsi 3 7,721 Jun-05-2020, 08:38 PM
Last Post: nuffink

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020