here a drag&drop example ( create also a test file > fx=%a_desktop%\Test Capture File.txt )
drag&drop different text files to convert ( time format 36:35.10 > 00:36:35.100000000 )
Code: Select all
;-https://www.autohotkey.com/boards/viewtopic.php?p=310518#p310518
/*
;- script from ahk-user TheDewd
;-- orig text ----------------
d5 17
12:02
23:30
36:35.10
41:19
;-- new text ------------------
00:12:02.000000000
00:23:30.000000000
00:36:35.100000000
00:41:19.000000000
;------------------------------
*/
;-------------------------------------------------------------
;- drag&drop different text-files and click on row in listbox
;- ( example xy.txt > xy_NEW.txt )
#warn
#NoEnv
setworkingdir,%a_scriptdir%
filename1=Drag&Drop Text-files
extensions:="txt,csv,bat,ahk,log,bas" ;- < extensions
gosub,testfile
GUI,2:+AlwaysOnTop
Gui,2: -DPIScale
Gui,2: Color, ControlColor, Black
Gui,2: Font, CDefault s14, Lucida Console
Gui,2:Add, ListBox, x5 y10 w1280 h200 cYellow gRun1 vF1,
GUI,2:show, W1300 H230 X20 Y200,%filename1%
return
2Guiclose:
exitapp
;-----------------------
2GuiDropFiles:
GuiControl,2:,F1
Loop, parse, A_GuiEvent, `n
{
SplitPath,a_loopfield, name, dir, ext, name_no_ext, drive
if ext in %extensions%
GuiControl,2:,F1,%A_LoopField%
}
return
;-----------------------
Run1:
Gui,2:submit,nohide
SplitPath, F1, name, dir, ext, name_no_ext, drive
fileread,timestamps,%f1%
newtime:=""
Loop, Parse, % Timestamps, `n,`r
{
If (RegExMatch(A_LoopField, "^(\d{2}):(\d{2})$", Match)) {
NewTime .= "00:" Match1 ":" Match2 ".000000000`n"
} Else If (RegExMatch(A_LoopField, "^(\d{4})$", Match)) {
RegExMatch(Match, "^(\d{2})(\d{2})$", Match)
NewTime .= "00:" Match1 ":" Match2 ".000000000`n"
} Else If (RegExMatch(A_LoopField, "^(\d{6})$", Match)) {
RegExMatch(Match, "^(\d{2})(\d{2})(\d{2})$", Match)
NewTime .= "00:" Match1 ":" Match2 "." Match3 "0000000`n"
} Else If (RegExMatch(A_LoopField, "^(\d{2}):(\d{2}):(\d{2})$", Match)) {
NewTime .= "00:" Match1 ":" Match2 ":" Match3 "0000000`n"
} Else If (RegExMatch(A_LoopField, "^(\d{2}):(\d{2}).(\d{2})$", Match)) {
NewTime .= "00:" Match1 ":" Match2 "." Match3 "0000000`n"
}
}
timestamps=
f2=%a_desktop%\%name_no_ext%_NEW.%ext%
ifexist,%f2%
filedelete,%f2%
fileappend,%newtime%,%f2%
run,%f2%
return
;------- create a test-file --------------------
testfile:
fx=%a_desktop%\Test Capture File.txt
e=
(Ltrim join`r`n
Season 2
ep3
11:29
37:04
45:35
ep4
14:41
24:11
45 36
ep5
21:33
32:37
45:33
EP6
22:08
31:34
38:26
43:55
ep7
26:32
37:20
43:56
ep8
08:35
26:29
45:30
9
22:00
35:36
45:19
10
08:24
19:34
44:03
11
11:12
34:40
45:27
12
14:43
28:29
37:00
45:29
13
05:24
18:27
37:01
43:50
14
13:37
26:00
32:45
47:10
15
12:35
27:30
45:28
16
21:56
32:04
45:32
d5 17
12:02
23:30
36:35.10
41:19
45:31
18
22:19
36:27
45:33
19
10:52
33:16
47:31
20
27:00
38:35
47:34
21
15:46
33:05
35:03
36:08
47:34
22
12:44
34:45
45:26
23
12:22
19:46
44:08
24
12:00
37:51
45:27
S3
D125
)
ifnotexist,%fx%
fileappend,%e%,%fx%
e=
return
;======================== END SCRIPT ==============