
PowerDicom
A Sample Script
The following sample script demonstrates how easy it is to anonymize all DICOM files in a whole folder using PowerDicom™. This script uses VBScript (Windows Script Host). Many other programming, scripting or macro languages can be used similar.
rem Sample Script anonymize.vbs
rem
rem This script changes the patient's name in each file of a given
rem folder and saves all files to a different directory
rem==========================================================================
rem Source and Destination Directories
SourceDir="files\"
DestDir=WScript.CreateObject("WScript.Shell").SpecialFolders("Desktop")+"\test\"
rem creating a filesystem object and the PowerDicom.Automation object
set fs=WScript.CreateObject("Scripting.FileSystemObject")
set PowerDicomAuto = WScript.CreateObject("PowerDicom.Automation")
if fs.FolderExists(SourceDir) then
set Files=fs.GetFolder(SourceDir).Files
else
WScript.Echo(SourceDir+" doesn't exist.")
WScript.Quit
end if
if Not fs.FolderExists(DestDir) then
fs.CreateFolder(DestDir)
end if
for each Item in Files
rem opening a DICOM-file
v= PowerDicomAuto.OpenFile(Item.Path)
if v>0 then
rem modify the Patient's name
PowerDicomAuto.SetItemValue &H10,&H10,"anonymous"
rem save the modified file
if PowerDicomAuto.SaveFile(DestDir+Item.Name)<1 then
WScript.Echo("Error Writing File "+ Item.Name + " to " + DestDir)
end if
rem close the file
PowerDicomAuto.CloseFile()
end if
next
WScript.Echo("Finished Anonymizing")
|

