Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :: "Dev History Ripper\Ripper.cmd"
- @echo off
- setlocal EnableDelayedExpansion
- :: Ensure the temp directory exists
- if not exist ".\temp" mkdir ".\temp"
- :: Cleanup previous temporary files
- call :wipe
- :: Execute clone, sort, and process phases
- call :clone
- call :process
- :: Generate final output file
- type ".\temp\process.temp" > ".\DEVNOTES.md"
- :: Uncomment the following line to clean temp files after processing
- call :wipe
- exit /b
- :wipe
- :: Define temp files to delete
- set "files=clone sort process"
- for %%f in (%files%) do (
- if exist ".\temp\%%f.temp" (
- del ".\temp\%%f.temp" /f /q
- )
- )
- exit /b
- :clone
- :: Gather all matching files and output to clone.temp
- type nul > ".\temp\clone.temp"
- dir "f:\?*.puzzlum.?*.test ????-????-???? (?*).7z" /aa /b >> ".\temp\clone.temp"
- dir "..\?*.puzzlum.?*.test ????-????-???? (?*).7z" /aa /b >> ".\temp\clone.temp"
- :: Sort the file list and remove duplicates
- sort ".\temp\clone.temp" /r /unique > ".\temp\sort.temp"
- exit /b
- :process
- :: Initialize the output file
- type nul > ".\temp\process.temp"
- setlocal enabledelayedexpansion
- :: Process each line from the sorted file list
- set "previous="
- set /a count = 0
- :: Process each line from the sorted file list
- for /f "usebackq delims=" %%A in (".\temp\sort.temp") do (
- set /a count = count + 1
- set "line=%%A"
- :: Default values for parsing
- set "prefix="
- set "timestamp="
- set "comment="
- :: Extract fields with robust parsing
- for /f "tokens=1* delims= " %%B in ("!line!") do (
- set "prefix=%%B"
- set "remainder=%%C"
- )
- for /f "tokens=1* delims= " %%D in ("!remainder!") do (
- set "timestamp=%%D"
- set "comment=%%E"
- )
- :: Validate timestamp length
- if "!timestamp!" neq "" if "!timestamp:~0,4!" lss "1000" (
- echo Skipping invalid line: !line!
- rem endlocal
- goto :continue
- )
- :: Cleanup and format comment
- set "comment=!comment:.7z=!"
- set "comment=!comment:~1,-1!"
- :: Reformat timestamp
- set "converted=!timestamp:~0,4! !timestamp:~5,2!/!timestamp:~7,2! !timestamp:~10,2!:!timestamp:~12,2!"
- set "dispheader=1"
- :: Check if the prefix has changed
- if /i "!prefix!" neq "!previous!" (
- set "header=### !converted! !count!: !prefix!"
- echo Writing new header: !header!
- echo !header! >> ".\temp\process.temp"
- set "previous=!prefix!"
- )
- :: Write the processed line
- set "line=-- **!converted! !count!: "!comment!"**"
- echo Writing line: !line!
- echo !line! >> ".\temp\process.temp"
- :continue
- endlocal
- )
- exit /b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement