在OSX上将.py(文本文件)批量转换为.pdf [英] Batch convert .py (text files) to .pdf on osx

查看:104
本文介绍了在OSX上将.py(文本文件)批量转换为.pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我教一个python课程,并且有大量的.py文件已提交给考试.我想将所有这些都转换为pdf,以便可以在ipad上的IAnnotate中打开它们,对其进行标记,然后将其返回给学生.如何在批处理模式下进行此类转换?

I teach a python course and have a large number of .py files that were submitted for an exam. I would like to convert all these to pdf so that I can open them in IAnnotate on my ipad, mark them up and return them to students. How can I do a such a conversion in batch mode?

推荐答案

在小牛上尝试过:

#!/bin/bash
for file in *.py; do
    textutil -convert rtf -font 'Courier New' -fontsize 9 ${file} -output ${file}.rtf
    cupsfilter -D ${file}.rtf > ${file}.pdf
done

生成的文件将被命名为*.py.pdf.

The resulting files will be named *.py.pdf.

这篇关于在OSX上将.py(文本文件)批量转换为.pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆