There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
DOS/PDA/Other
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
Batch File Help


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
lennep's Avatar
Junior Member with 2 posts.
 
Join Date: Jul 2007
Experience: Intermediate
19-Jul-2007, 09:18 AM #1
Batch File Help
Can someone help with batch file? OS is XP Pro.

We are trying to delete or keep files based on a "tag" within the target file.

The file type is dicom (.dcm), the standard medical imaging format. One of the "tags" within the individual dicom file identifies its source, i.e xray, CT, MRI or ultrasound.

We have a command line utility that can identify the required the tag within a .dcm file and save it to the same directory as the dicom file as a .txt file with the same name.

For example, a new file image1.dcm is identified in the parent directory and the utilility identifies it as a CT file. It creates a new file called image1.txt containing text "CT" in the same directory.Image2.dcm may be an ultrasound, and when identified, the file image2.txt which contains text "US"is created in the same directory .

The directory now contains 4 files: image1.dcm; image2.dcm: image1.txt: image2.txt.

I only want to keep files with the "CT" tag and delete the others.

The question is:

How can we create a batch file which compares the .txt/.dcm files of the same name and deletes image2.dcm based on the "US" identifier whilst keeping image1.dcm based on its "CT" identifier.

I presume there must be a "true" or "false" argument created by comparing the .txt and .dcm files based on the .txt file script content.

If the script is "CT", the argument is true and the file is left intact. If the script is "US", the argument is false and then DEL file command instruction issued to remove image2.dcm.

I know this seems messy but all of our attempts to tackle this one have failed due to our rudimentary DOS skills.

Any assistance appreciated.

lennep
Squashman's Avatar
Distinguished Member with 12,598 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
19-Jul-2007, 09:47 AM #2
I am wondering if you could do this with the Builtin functionality of XP. Since these are digital images, they should have some type of tag that says Camera model or something. You can chose that as one of the details to show in Explorer. You can then sort by that column and select the images you want. Of course I don't know if XP will see a DCM file as an Image and show you the correct tags.
__________________
I hate asking the same question twice!
How to ask questions the smart way!
Microsoft MVP - Windows Shell/User
Squashman's Avatar
Distinguished Member with 12,598 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
19-Jul-2007, 10:03 AM #3
Basically what you need is a piece of software that can organize your Dicom images by its tag information. There seems to be alot of software out there that does this already. This is very similar to all the software out there that does this with the EXIF information tags of a normal digital camera you would buy.

I did various Google searches with DICOM in the search parameters and I am sure you can find some software that does this for you instead of having to screw around with a Batch File.
__________________
I hate asking the same question twice!
How to ask questions the smart way!
Microsoft MVP - Windows Shell/User
dez_666's Avatar
Computer Specs
Senior Member with 856 posts.
 
Join Date: May 2007
Location: Kalifornya
Experience: Advanced
19-Jul-2007, 01:37 PM #4
I dont know if this will help you, but XnView can read Dicom (*.dcm) files.
lennep's Avatar
Junior Member with 2 posts.
 
Join Date: Jul 2007
Experience: Intermediate
19-Jul-2007, 07:32 PM #5
I wish it were that simple.

What we are currently doing is copying new images which are being constantly sent a network directory from various imaging modalities (CT,MRI, ultasound etc) to a local drive C:\temp. This is easily done by a nice program called WatchDirectory which monitors a drive and immediately copies newly created files to \temp. No problems there.

WatchDirectory also monitors C:\temp for new file arrivals. When they arrive, it launches the .bat below which I created after much research on various forums. It selects and deletes files samller than 450kb and larger than 910kb and then imports the remaining images into the program EFilm, a medical viewer. The -d then deletes the imported images once the run is completed. This size range selects the modalites I want to keep reasonably well and deletes the rest before Efilm Import starts.

Unfortunately, some of the images I want to keep from MRI are in the 150kb range and are therefore deleted before import. Whilst I could drop my delete size, this would select a large number of unwanted files.

Using the utility that finds an image tag and creates an associated txt file identifes the source of the image as being CT, MRI etc., but it does not have the ability to do anything other than write a text file with the content 'CT', 'MRI' etc with the same file name as the original image.

Hence my question - as my current batch file only selects on the basis of size, can I write one that compares txt and dcm files and deletes or keeps dcm on the basis of the txt script? I only want to keep CT and MRI.

cd\temp
FOR %%F IN (*.*) DO (
IF %%~zF LEQ 450000 DEL %%F
IF %%~zF GEQ 910000 DEL %%F
)
"C:\Importer\wscript.exe "C:\Importer\invisible.vbs""
"C:\Program Files\Merge eFilm\eFilm\efDcmIm.exe" C:\temp -d
exit


lennep
dez_666's Avatar
Computer Specs
Senior Member with 856 posts.
 
Join Date: May 2007
Location: Kalifornya
Experience: Advanced
19-Jul-2007, 07:38 PM #6
Why not just make different directories and import a directory?

Like have one kind of image be sent to one folder, another kind to another folder, and then when they are transferred they would appear as

C:\temp\MRI\anmrifile.dcm
C:\temp\CT\aCTfile.dcm

like that..?
Squashman's Avatar
Distinguished Member with 12,598 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
23-Jul-2007, 11:13 PM #7
If this utility it a command line utility, you should be able to redirect stdout to a utility like grep. Tell grep to look for CT and if true then move the file it is working on to another directory.
ghostdog74's Avatar
Member with 90 posts.
 
Join Date: Dec 2005
24-Jul-2007, 03:15 AM #8
Quote:
Originally Posted by lennep
The question is:
How can we create a batch file which compares the .txt/.dcm files of the same name and deletes image2.dcm based on the "US" identifier whilst keeping image1.dcm based on its "CT" identifier.
no batch..but vbscript.
Code:
Option Explicit
Dim myDir,objFSO,objFolder,Files,FileExt,FileName,objFile
Const ForReading=1
myDir="c:\temp"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(myDir)
For Each Files In objFolder.Files
	FileExt = objFSO.GetExtensionName(Files)
	If  FileExt = "dcm" Then
		FileName=objFSO.GetBaseName(Files)
		If objFSO.FileExists(myDir&"\"&FileName & ".txt") then
			Set objFile = objFSO.OpenTextFile(myDir&"\"&FileName & ".txt", 1)
			Do Until objFile.AtEndOfLine
			  If InStr(1,objFile.ReadLine,"US")  Then
			  	objFSO.DeleteFile(myDir&"\"&FileName & "."&FileExt)
			  End If 
			Loop
			Set objFile = Nothing
		End If 
	End If
Next
Squashman's Avatar
Distinguished Member with 12,598 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
24-Jul-2007, 01:39 PM #9
Where is it checking to see if image.txt contains CT?
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 12:58 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.