AutoHotkey: Create .bat file to combine file parts: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(added .exe version) |
||
Line 59: | Line 59: | ||
; Write .bat file | ; Write .bat file | ||
FileAppend, %CombineString%, %OutputFile% | FileAppend, %CombineString%, %OutputFile% | ||
A compiled .exe version of this script is also available: [http://thehacker.totalcmd.net/batchcombine/batchcombine.exe batchcombine.exe] | |||
Back to [[AutoHotkey]] | Back to [[AutoHotkey]] |
Revision as of 21:23, 25 November 2005
This script creates a batch file that can be used to combine file parts created using File - Split File.
Usage:
- create a button in the Button Bar or a Start menu entry pointing to this script
- enter "%L" in the Parameters field
- use by selecting file parts file.001 - file.nnn and clicking on the script button (menu entry)
; Check number of parameters ; %0% is the number of parameters ; In "If" it must be referenced as 0, not %0% IfNotEqual, 0, 1 { MsgBox, Error: Exactly one parameter "`%L" required.`n`nNumber of parameters passed: %0%`n`nExiting. Exit } ; Check if listfile exists IfNotExist, %1% { MsgBox, Error: List file "%1%" not found.`n`nExiting. Exit } ; Check if default output file does not already exist FileReadLine, FirstFilePart, %1%, 1 StringGetPos, DotPos, FirstFilePart, ., R StringLeft, OutputFile, FirstFilePart, DotPos CrcFile = %OutputFile%.crc OutputFile = %OutputFile%.bat IfExist, %OutputFile% { MsgBox, Error: Output file "%OutputFile%" already exists.`n`nExiting. Exit } ; Check if .crc file exists (to retrieve original filename) IfNotExist, %CrcFile% { MsgBox, Error: CRC file "%CrcFile%" not found (needed to know original filename).`n`nExiting. Exit } ; Create combine command string CombineString = @copy /b%A_Space% Loop, Read, %1% { StringGetPos, BackslashPos, A_LoopReadLine, \, R StringTrimLeft, CurrFileName, A_LoopReadLine, BackSlashPos + 1 CombineString = %CombineString% "%CurrFileName%" + } StringTrimRight, CombineString, CombineString, 1 ; Get original filename FileReadLine, OrigName, %CrcFile%, 1 StringTrimLeft, OrigName, OrigName, 9 CombineString = %CombineString%"%OrigName%" ; Write .bat file FileAppend, %CombineString%, %OutputFile%
A compiled .exe version of this script is also available: batchcombine.exe
Back to AutoHotkey