I am trying to convert a large number of .jpg files to the medical image format .dcm. There are many folders (with no subfolders) within a directory called C:\dicom. Each of these contains a patient specific .jpg called "REF.jpg" that needs to be converted to a file called "request.dcm" by using a small utility called img2dcm located in C:.
Each folder also contains a patient specific file called "IMG.dcm" used as a template for the conversion.Patient specific metadata is inserted from the template into the newly created request.dcm file.
For an individual folder called "foldername" containing the "REF.jpg" file, and the template file "IMG.dcm", the following command line (including the spaces) will create a usable "request.dcm" file in the same folder:
img2dcm foldername\REF.jpg foldername\request.dcm -stf foldername\IMG.dcm -k "Ser
iesDescription"=REQUEST -k "Modality"=OT -k "SeriesNumber"=200 -k "ImageNumber"=
1"
What I need to do is create a batch file to loop this command through every folder in the directory, all differently named but all containing the required files. It is crucial the newly created file be placed within its parent folder.
Any help would be greatly appreciated for what is a fairly daunting project for a someone without an IT or computing background.
#echo off
c:
cd \dicom
for /d %%i in (*) do (
img2dcm c:\dicom\%%i\REF.jpg c:\dicom\%%i\request.dcm -stf c:\dicom\%%i\IMG.dcm -k "Ser iesDescription"=REQUEST -k "Modality"=OT -k "SeriesNumber"=200 -k "ImageNumber"= 1"
)
should accomplish this.
I'd suggest you copy a portion of your data to a test subdirectory (say C:\DUMMY) and run that routine - having changed dicom throughout to dummy
Related
I am using PDFtk-server to merge 2 PDF files. This creates a new PDF with name Test_.
Now, what I am looking for is a batch files that renames the Test_ files to Test_datestamp and then move them into another folder and delete the files.
It is working if only one file is present.
pdftk C:\test\*.pdf C:\test\file-to-add\file.pdf cat output C:\test\output\Test_.pdf
ren "C:\test\output\*pdf" "Test_ - %date:/=.% %time::=-%.pdf"
del C:\test\*.pdf
Then comes to copy part to other folders.
If having multiple files, the first one gets renamed but other not, because it is trying to set the same timestamp, so I need some kind of delay between renaming.
I want to copy some of the files to the specific folder after the successful compilation of the project. I have written a post build event as mentioned below:
xcopy "$(ProjectDir)bin" "$(TargetDir)..\..\Support Files\DBUpgradeUtility\" /Y
Note: the output path of my project has been set to bin folder for debug and release both the mode.
The above mentioned build event worked fine and all the files present under bin folder has been copied to destination folder. But along with the required files, the ‘vshost.exe’ files also copied, I don’t’ want this file. So, I have used the exclude parameter of xcopy build event as mentioned below:
xcopy "$(ProjectDir)bin" "$(TargetDir)..\..\Support Files\DBUpgradeUtility\" /Y /exclude:$(TargetDir)..\..\Support Files\DBUpgradeUtility\*.vshost.exe
With the above build event, the compilation failed and the error was:
The command "xcopy "C:\TFSWorkspace\FASTER.Web -
v6.3.Sprint.06\Source\Installer\Application\DBUpgradeUtility\bin"
"C:\TFSWorkspace\FASTER.Web -
v6.3.Sprint.06\Source\Installer\Application\DBUpgradeUtility\bin....\Support
Files\DBUpgradeUtility\" /Y /exclude:"C:\TFSWorkspace\FASTER.Web -
v6.3.Sprint.06\Source\Installer\Application\DBUpgradeUtility\bin....\Support
Files\DBUpgradeUtility*. vshost.exe" exited with code 4.
I have also googled for exclude parameter and then written the build event mentioned above. I cannot find what I am missing here or what I did wrong.
Please help me on this.
Thank you.
The /exclude option of the xcopy command works differently - it allows you to specify files which contain exclude filters:
Specifies a list of files. At least one file must be specified. Each
file will contain search strings with each string on a separate line
in the file.
When any of the strings match any part of the absolute
path of the file to be copied, that file will be excuded from being
copied. For example, specifying the string, \obj\ or .obj will exclude
all files underneath the directory obj or all files with the .obj
extension.
Therefore you may create a new file in your project (for example $(ProjectDir)excludes.txt) and add this line:
vshost.exe
Then change the option in your xcopy command to:
/exclude:"$(ProjectDir)excludes.txt"
This excludes all files containing vshost.exe in their absolute path. If you have to exclude other files, just add a new line to the file.
Please can someone help with the below
I have two folders:
C:\FolderA
C:\FolderB
Folder A contains a bunch of files like an archive
Folder B contains the same bunch of files with the same name, however some data within the files may be different.
I want to write a .bat file which uses the diff command to compare all the files from folder A to the files in folder B with the corresponding name (e.g. update0001 against update 0001) and outputs the difference in "C:\Folder C" with each file difference in a separate text output. (e.g one file is called “Error update0001” and another “Error Update0005”
This is a simple way to check the files in two folders and give results.
fc /b "c:\folder a\*.*" "c:\folder b\*.*" >"c:\folder c\results.txt"
I have some java executable program initialized from cmd. My problem is as following: I would like to read all files from some directory. Next, I would like to run the program as many times as many files I have in my folder. The required inputs are the path to the file with data and the name of the file where the results will be written. Now my question is, how can I write a simple batch file which will do it for me?
For example:
I have a list of files in my folder
file_1.xls
file_2.xls
file_3.xls
I want to run a loop and for each file initialize line specified below:
java -jar -Xmx1000M Program.jar pathToInputFile PathToOutputfile
For example for file file_1.xls I want to write the result to the file with the same name but different extension and at the begining of this file add some constant prefix. In case of file_1.xls the results I would like to write as Output_file_1.txt
for file_2.xls -> Output_file_2.txt
for file_3.xls -> Output_file_3.txt
and so on...
Can anyone help me?
pushd "c:\excel_files"
for %%F in (*.xls) do (
java -jar -Xmx1000M Program.jar "%%~nxF" "Output_%%~nF.txt"
)
Though I'll recommend you to use -classpath and direct call of the entry point class instead of direct call of the .jar .
I am completely new to this, but I am trying to create a .bat file that will allow me to rename a pair of files within a designated folder and move them into a subfolder. The part I am having trouble with is that I am wanting a prompt to come up to identify/select the files to be renamed and moved.
Example file names are:
A1234, A1235, A1236, B1234, B1235, B1236, etc.
Is there a way to bring up a prompt that allows the user to type the shared name (ex 1234)of the files and rename and move both files to the designated subfolder?
Any and all help would be appreciated!
Suggested approach
for part of problem
part I am having trouble with is that I am wanting a prompt to come
up to identify/select the files to be renamed and moved. Is there a
way to bring up a prompt that allows the user to type the shared name
(ex 1234)of the files and rename and move both files to the designated
subfolder?
Do a search operation using wildcard, like "?1234" for the case highlighted above ( should be made generalized for all acceptable and expected patterns "*1234*" is the generic most )
Now do a RENAME inside a For loop on the results obtained by search.
As you suggest you are a newbie with Batch, following tutorials will help you build your file. Look for elements like Variables, For Loop
Batch Tutorial
Here you go
#echo off
set /p file=Please type shared name:
for %%a in (C:\Folder\?%file%.*) do (
move "%%a" subdir
ren "subdir\%%a" newname.*
)