Modify Python Script to Batch Convert all “WOFF” Files in Directory

后端 未结 2 921
半阙折子戏
半阙折子戏 2021-01-07 04:27

I have been using a great open-source python script by GitHub user @hanikesn (see below) that converts a single WOFF file back into OTF format via command line (Terminal on

相关标签:
2条回答
  • 2021-01-07 05:07

    You are using zsh, aren't you? so to loop on your WOFF files you could to do

    for f in *.woff ; /complete/path/to/your/script.py $f
    
    0 讨论(0)
  • 2021-01-07 05:08

    If you want create an Drag&drop app, you could:

    • open the Automator.app
    • select "Application"
    • in the left-side Library find the Filter Finder Items action
    • drag it into the right
    • add the extenstion is woff condition
    • in the Library find the Run Shell Script action
    • change the Pass input popup to as arguments
    • drag&drop the your woff2otf.py into the place of the echo (you will get it's full path name)
    • save the app somewhere as woff2otf.app
    • congratz - you're done with your 1st OS X application. :)

    Just drag the woff files into the application icon and it should convert them. I can't test it, because i havent installed python3.

    The final app should be as in the following screenshot:

    EDIT: If your python3 command isn't in the standard command search $PATH, you must change the line:

    • /path/to/the/woff2otf.py "$f" to
    • /path/to/your/python3 /path/to/the/woff2otf.py "$f"

    I installed python3 using anyenv - e.g. it wont help you. Therefore my python3 is:

    $ type python3
    python3 is /opt/anyenv/envs/pyenv/shims/python3
    

    so the line in the shell script (for me) looks like:

    /opt/anyenv/envs/pyenv/shims/python3 ~/bin/woff2otf.py "$f"
    

    But, your installation is surely different.

    Also could help:

    • where is login bash script or ~/.profile MAC
    • Check if a program exists from a Bash script
    • How to edit path variable in ZSH
    • How to show zsh function definition (like bash "type myfunc")?
    • Where to place $PATH variable assertions in zsh?
    • and more like the above
    0 讨论(0)
提交回复
热议问题