Please help me with this shell script
Ramiro Espinoza
Posts: 839
Hi there,
I am trying to improve the coarse shell script I am using to use TTFAutohint in batch.
Currently I am doing:
But my method for saving the output is very clumsy: I am renaming the files and then moving them to a new directory.
I would like to just save the output in the new directory, but all my attempts have failed.
Can anyone help me with this?
Thanks in advance.
I am trying to improve the coarse shell script I am using to use TTFAutohint in batch.
Currently I am doing:
#!/bin/sh for file in /Users/RamiroLaptop/Desktop/03-TTFAutohint/* do ttfautohint -v -f latn -n -w G "$file" "$file-HINTED.ttf" mkdir /Users/RamiroLaptop/Desktop/03-TTFAutohint/Hinted-Fonts mv /Users/RamiroLaptop/Desktop/03-TTFAutohint/*-HINTED.ttf /Users/RamiroLaptop/Desktop/03-TTFAutohint/Hinted-Fonts done
But my method for saving the output is very clumsy: I am renaming the files and then moving them to a new directory.
I would like to just save the output in the new directory, but all my attempts have failed.
Can anyone help me with this?
Thanks in advance.
Tagged:
0
Comments
-
Try this, to be use as
script.sh path/to/font/dir/
:#!/bin/sh<br><br>pushd $1<br>mkdir -p Hinted-Fonts<br><br>for file in *<br>do<br> ttfautohint -v -f latn -n -w G "$file" Hinted-Fonts/"$file" <br>done
1 -
The fact is I like to run it double clicking a .command file because I don't have to type anything. Can you add the output path inside the script? I've tried several combination but I always get:
</code>The following error occurred while opening font `/Users/RamiroLaptop/Desktop/03-TTFAutohint/Hinted-Fonts//Users/RamiroLaptop/Desktop/03-TTFAutohint/LaskiSans-RegularItalic.ttf': <span style="font-family: 'Alright Sans from Webtype', 'Lucida Sans Unicode', 'Lucida Sans', 'Lucida Grande';"><pre class="CodeBlock"><code> No such file or directory
Obviously I can't get the dynamic output address right.
0 -
Just replace $1 with the path you want.
1 -
Thanks! It works as a charm. I just modified the loop so it does not run on the folder:
for file in *.ttf
0 -
You could test for an item being a file with
if [ -f $file ] then
...
fi
this allows your script to do ttc and dfont, for example. Items not ending with ttf.0 -
I left the wild card as it was in your original script. @Hin-Tak Leung is good as well, or you can use a list of extensions *.{ttf,ttc,dfont} etc. though I don’t think ttfautohint handles all of these anyway.
0
Categories
- All Categories
- 43 Introductions
- 3.7K Typeface Design
- 801 Font Technology
- 1K Technique and Theory
- 618 Type Business
- 444 Type Design Critiques
- 542 Type Design Software
- 30 Punchcutting
- 136 Lettering and Calligraphy
- 83 Technique and Theory
- 53 Lettering Critiques
- 483 Typography
- 301 History of Typography
- 114 Education
- 68 Resources
- 499 Announcements
- 80 Events
- 105 Job Postings
- 148 Type Releases
- 165 Miscellaneous News
- 269 About TypeDrawers
- 53 TypeDrawers Announcements
- 116 Suggestions and Bug Reports