Repository navigation
Expand file tree
/
Copy pathTranscript Scrubber.ahk
More file actions
69 lines (57 loc) · 2.17 KB
/
Copy pathTranscript Scrubber.ahk
File metadata and controls
69 lines (57 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
; Written for AutoHotKey v2.0.18
; This work © 2025 by G Rich Jeanes (https://github.com/RichJeanes/transcript-scrubber) is licensed under
; Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)
MainGui := Gui(, "Transcript Scrubber")
MainGui.Opt("AlwaysOnTop")
MainGui.SetFont("S16")
MainGui.Add("Text", "W300 H200 Center +0x200", "Drag and drop your file here.")
MainGui.OnEvent("DropFiles", Gui_DropFiles)
MainGui.Show()
Gui_DropFiles(GuiObj, GuiCtrlObj, FileArray, X, Y) {
for i, File in FileArray
ProcessFile(File)
}
ProcessFile(inputPath) {
SplitPath(inputPath, &inputFileName, &inputFileDir, &inputFileExt, &inputFileNameNoExt)
; Display Save dialog
outputPath := FileSelect("S16", inputFileDir . "\" . inputFileNameNoExt . " - Minimized.txt", "Select Save Location", "Plain Text (*.txt)")
if (outputPath = "") {
; User cancelled Save dialog
Exit 1
}
SplitPath(outputPath, &outputFileName, &outputFileDir, &outputFileExt, &outputFileNameNoExt)
if (outputFileExt != "txt") {
; Force ".txt" file extension
outputPath := &outputFileDir . outputFileNameNoExt . ".txt"
}
oWord := ""
Switch inputFileExt {
Case "doc", "docx":
; Open file in Word and copy the contents
oWord := ComObject("Word.Application")
oWord.Documents.Open FileName:=inputPath
Clipboard := '', oWord.ActiveDocument.Range().FormattedText.Copy()
oWord.Quit
Default:
MsgBox("Unsupported file type.")
Exit 2
}
; Wait for data to be on the clipboard
if (!ClipWait(5)) {
MsgBox("Text copy failed!",, "icon!")
ExitApp 1
}
; Ensure clipboard is plain text
A_Clipboard := A_Clipboard
; Remove timestamps and the following newline
; If you aren't familiar with Regular expressions but are feeling adventurous,
; use https://regex101.com/ for an explanation of what this is doing
interviewText := RegExReplace(A_Clipboard, "[ ]{3}(([0-9]{1,2}:){1,2})[0-9]{2}\r\n", " ")
; Remove blank lines
interviewText := RegExReplace(interviewText, "(\r\n){2}", "`r`n")
; Write results
outputFile := FileOpen(outputPath, "rw")
outputFile.Write(interviewText)
outputFile.Close()
MsgBox(Format("File saved to:`n{1}", outputPath),, "T5")
}