How to make a valid Windows filename from an arbitrary string?

后端 未结 14 1154
伪装坚强ぢ
伪装坚强ぢ 2020-12-23 02:50

I\'ve got a string like \"Foo: Bar\" that I want to use as a filename, but on Windows the \":\" char isn\'t allowed in a filename.

Is there a method that will turn \

14条回答
  •  忘掉有多难
    2020-12-23 03:12

    You can do this with a sed command:

     sed -e "
     s/[?()\[\]=+<>:;©®”,*|]/_/g
     s/"$'\t'"/ /g
     s/–/-/g
     s/\"/_/g
     s/[[:cntrl:]]/_/g"
    

提交回复
热议问题