Closed zdavatz closed 1 year ago
This script will do the trick:
$directory = 'S:\GDT-E-PAT-Vitabyte'
$originalFileName = 'epat.gdt'
# Check if the file exists in the directory
$files = Get-ChildItem -Path $directory -Filter $originalFileName
if ($files.Count -gt 0) {
$timestamp = Get-Date -Format 'yyyyMMddHHmmss'
$counter = 1
foreach ($file in $files) {
$extension = $file.Extension
$newName = "$timestamp" + "_epat_$counter" + $extension
$newPath = Join-Path -Path $directory -ChildPath $newName
Rename-Item -Path $file.FullName -NewName $newPath
$counter++
}
Write-Host "Files renamed successfully."
} else {
Write-Host "No files named '$originalFileName' found in the directory."
}
$gdtDirectory = 'S:\GDT-E-PAT-Vitabyte'
$outputDirectory = 'C:\Users\medi-lan\gdt2dicom\dicom\medilan_MWL'
$gdt2dicomExe = 'C:\Users\medi-lan\gdt2dicom\gdt2dicom.exe'
# Create the output directory if it doesn't exist
if (-not (Test-Path -Path $outputDirectory)) {
New-Item -ItemType Directory -Path $outputDirectory | Out-Null
}
# Get all GDT files in the input directory
$gdtFiles = Get-ChildItem -Path $gdtDirectory -Filter '*.gdt'
foreach ($gdtFile in $gdtFiles) {
$outputFile = Join-Path -Path $outputDirectory -ChildPath ($gdtFile.Name -replace '\.gdt$', '.wl')
& $gdt2dicomExe --gdt-file $gdtFile.FullName --output $outputFile
}
Get-ChildItem -Path $outputDirectory -Filter "*.wl" | ForEach-Object {
& "dcmodify" -i "0008,0060=ECG" "$($_.FullName)"
& "dcmodify" -i "0032,1060=holter" "$($_.FullName)"
}
dcmodify -i "0008,0060=ECG" test.dcm
dcmodify -i "0032,1060=holter" test.dcm
gdt2dicom --gdt-file epat.gdt --output epat.wl
gdt2dicom --gdt-file epat.gdt --tag 0008,0060=ECG,0032,1060=holter --output epat.wl