LoginSignup
1
1

More than 1 year has passed since last update.

パワポの各スライドの原稿をコマンド一行でまとめて出力する方法

Last updated at Posted at 2021-12-14

やりたいこと

パワポの各スライドの原稿(発表者ノートに書いた文章)を、まとめて一気に出力する

使用環境

Python 3.8.5
macOS Big Sur バージョン 11.2
Apple M1

1, Pythonファイルを1つ準備

以下のスクリプトをコピペして、"manuscript_extraction.py"というファイル名で対象のパワポファイルと同じフォルダ内に配置。

manuscript_extraction.py
from pptx import Presentation
#同じディレクトリにあるpptxファイルを指定すること
presentation = Presentation('プレゼンファイル.pptx')
for slide in presentation.slides:
    if slide.has_notes_slide and slide.notes_slide.notes_text_frame.text:
        append_file = open('manuscript.txt', 'a')
        append_file.write(slide.notes_slide.notes_text_frame.text)
        append_file.write('\r\n')
        append_file.write('-----')
        append_file.write('\r\n')
    append_file.close()

フォルダ構造はこんな感じ。
スクリーンショット 2021-08-23 23.33.05.png

2, python-pptxをインストール

PythonでPowerPointを操作するに、「python-pptx」という外部ライブラリをTerminal上でインストール。

Terminal
% !pip install python-pptx

3, スクリプトとパワポファイルのあるディレクトリに移動

Terminal

% cd Desktop/slide_note_script
% ls
manuscript_extraction.py        プレゼンファイル.pptx

4, 先程のプログラム"manuscript_extraction.py"をpythonで実行。

Terminal
% python3 manuscript_extraction.py
% ls
manuscript.txt              プレゼンファイル.pptx
manuscript_extraction.py

以下の通り、同じディレクトリー内にmanuscript.txtという原稿のファイルができました。
スクリーンショット 2021-08-23 23.32.43.png

こちら中身を確認するとこんな感じで原稿ができてます。

スクリーンショット 2021-08-23 23.31.33.png

完璧ですね!

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1