Pat Malone
New Member
- Joined
- Jun 6, 2019
- Messages
- 8
$BaseDirectory = "C:\Users\Justin\Desktop\TestDirectory"
$NotesDirectory = "\Notes"
$CombinedNotesFile = "\CombinedNotes.txt"
$NoteList = "\List.txt"
$NoteFiles = Get-Content -Path "$($BaseDirectory)$($NoteList)"
foreach($NoteFile in $NoteFiles)
{
    $NoteContent = Get-Content -Path "$($BaseDirectory)$($NotesDirectory)\$NoteFile"
    $NoteName = $NoteFile.Replace(".txt"," - ")
    Out-File -InputObject $("$($NoteName)$NoteContent") -FilePath "$($BaseDirectory)$CombinedNotesFile" -Append
}$BaseDirectory = "C:\Users\Justin\Desktop\TestDirectory"
$NotesDirectory = "\Notes"
$CombinedNotesFile = "\CombinedNotes.txt"
$NoteList = "\List.txt"
$NoteFiles = Get-Content -Path "$($BaseDirectory)$($NoteList)"
foreach($NoteFile in $NoteFiles)
{
    $NoteContent = Get-Content -Path "$($BaseDirectory)$($NotesDirectory)\$NoteFile"
    $NoteName = $NoteFile.Replace(".txt"," - ")
    Out-File -InputObject $("$($NoteName)$NoteContent") -FilePath "$($BaseDirectory)$CombinedNotesFile" -Append
}Thank you so much! The solution I came up with created extra junk data so this was very helpful.I can look when I get home. Basically the more structured the data the easier it is to parse.
Looking briefly at the txt file I don't think it will be too difficult.
I'm not against donations lol. They're not necessary though.
Powershell is pretty powerful so the code can be changed to suit almost any need/behavior.
You could change this line
$NoteName = $NoteFile.Replace(".txt"," - ")
to
$NoteName = $NoteFile.ToLower().Replace(".cst"," - ")
to accommodate the the note files .cst extension.
and
change foreach($NoteFile in $NoteFiles)
to
foreach($NoteFile in $NoteFiles[1..$($NoteFiles.Count-1))
to ignore the first line