;@Ahk2Exe-ConsoleApp #Requires AutoHotkey v2 #SingleInstance Off Persistent(true) FileEncoding("UTF-8") SetWorkingDir(A_InitialWorkingDir) message := " ( Usage: clip.exe [parameters] [file-path] Parameters: -h `tDisplays this help message. -d `tSet the delimiter. -t `tSet a literal string. Examples: echo text | clip.exe `tCopy a literal string. clip.exe < file.txt `tCopy the content from a file. clip.exe -t text `tCopy a literal string. clip.exe a.txt b.txt `tCopy the content from 2 files. )" if ProcessGetName(ProcessGetParent()) == "explorer.exe" { Run(Format('"{}" /k call "{}" -h', A_ComSpec, A_ScriptFullPath)) ExitApp() } if Args(1) == "-h" { Print(message) ExitApp() } delimiter := "" content := FileOpen("*", "r").Read() loop A_Args.Length { cmd := Args(A_Index) arg := Args(A_Index + 1) if cmd == "-d" { delimiter := arg A_Index++ } else if cmd == "-t" { if content !== "" content .= delimiter content .= arg A_Index++ } else { if content !== "" content .= delimiter try content .= FileRead(cmd) catch Error as e { Print(e.Message, "**") } } } A_Clipboard := content ExitApp() Args(index, defarg:="") { try return A_Args[index] return defarg } Print(str:="", fn:="*", values*) { FileAppend(Format(str . "`n", values*), fn) }