tool script to convert back slash

Back slash is used in windows, which makes so many headache for me. Then an idea came to my mind. It's

  1. writing a python script to modify my clipboard content, and
  2. creating a listary command to call the script.

steps

  1. create the script D:\tool\slash_convertion.py with following content.
import re
import clipboard

text = clipboard.paste()
lsA = text.splitlines()
lsB = []
for line in lsA:
    line = re.sub(r"\\", "/", line)
    theMatch = re.search("^\"*(.*?)\"*$", line)
    # print(theMatch)
    line = f'"{theMatch.groups()[0]}"'
    lsB.append(line)
text = "\n".join(lsB)
text += "\n"
# print(text.encode("utf8"))
# print(text)
clipboard.copy(text)
  1. create listary command
  2. input keyword slash to modify you clipboard content.

posted on 2022-10-21 23:19  yusisc  阅读(17)  评论(0编辑  收藏  举报

导航