Sponsored Content
Full Discussion: shell
Top Forums Shell Programming and Scripting shell Post 302598181 by s00saa on Monday 13th of February 2012 04:43:54 PM
Old 02-13-2012
Thanks, but errors

Code:
test: moving 0001.dcm to /path/to/a/0001.dcm
test: moving 0002.dcm to /path/to/a/0002.dcm
test: moving 0003.dcm to /path/to/a/0003.dcm
test: moving 0004.dcm to /path/to/a/0004.dcm
test: moving 0005.dcm to /path/to/a/0005.dcm
test: moving 0011.dcm to /path/to/b/0011.dcm
test: moving 0012.dcm to /path/to/a/0012.dcm
test: moving 0013.dcm to /path/to/a/0013.dcm
test: moving 0014.dcm to /path/to/a/0014.dcm
test: moving 0015.dcm to /path/to/a/0015.dcm
test: moving 0021.dcm to /path/to/b/0021.dcm
test: moving 0022.dcm to /path/to/b/0022.dcm
test: moving 0023.dcm to /path/to/b/0023.dcm
test: moving 0024.dcm to /path/to/a/0024.dcm
test: moving 0025.dcm to /path/to/a/0025.dcm
test: moving 0031.dcm to /path/to/a/0031.dcm
test: moving 0032.dcm to /path/to/b/0032.dcm
test: moving 0033.dcm to /path/to/b/0033.dcm
test: moving 0034.dcm to /path/to/b/0034.dcm
test: moving 0035.dcm to /path/to/b/0035.dcm
test: moving 0041.dcm to /path/to/a/0041.dcm
test: moving 0042.dcm to /path/to/a/0042.dcm
test: moving 0043.dcm to /path/to/a/0043.dcm
test: moving 0044.dcm to /path/to/b/0044.dcm
test: moving 0045.dcm to /path/to/b/0045.dcm
test: moving 0046.dcm to /path/to/b/0046.dcm
test: moving 0047.dcm to /path/to/b/0047.dcm
test.sh: line 6: 0048: value too great for base (error token is "0048")

----------------------------------------------------------------------------------------------------------------------------------------------------

Quote:
Originally Posted by jim mcnamara
assumes directory A and b both exist. try this:
Code:
#!/bin/bash
cd /path/to/dcm_files
for i in *.dcm
do
    num=${i%%.*}
    num=$(( $num % 10 ))
    if [ $num -lt 6 ]; then
        echo "test: moving $i to /path/to/a/${i}"   # comment out this line after testing
   #    mv $i  /path/to/a/${i}   #uncomment after you TEST this
    else
         echo "test: moving $i to /path/to/b/${i}"   # comment out this line after testing
   #    mv $i /path/to/b/${i}   # uncomment after you TEST this
     fi
done


Last edited by Scott; 02-14-2012 at 05:41 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to run unix commands in a new shell inside a shell script?

Hi , I am having one situation in which I need to run some simple unix commands after doing "chroot" command in a shell script. Which in turn creates a new shell. So scenario is that - I need to have one shell script which is ran as a part of crontab - in this shell script I need to do a... (2 Replies)
Discussion started by: hkapil
2 Replies

2. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

3. Linux

How to Start a Shell as Login shell instead of ordinary shell

Hi I tried with bash --login option. but the output is siva:~$ bash --login siva:~$ is there any way to make the shell ask for user id and password ( and login as different user instead of using sudo / su ) Thx in advance Siva (3 Replies)
Discussion started by: Sivaswami
3 Replies

4. Shell Programming and Scripting

Help need to make a shell script run for ffmpeg vhook watermaking in shell

i have a small problem getting a batxh shell script to run in shell this is the code the problem seems to be centered around the ffmpeg command, something maybe to do with the ' ' wrapping around the vhook part command this is a strange problem , if i take the ffmpeg command and... (1 Reply)
Discussion started by: wingchun22
1 Replies

5. Shell Programming and Scripting

How to run cmds after changing to a new env (shell) in a shell script

Hi, I am using HP-UNIX. I have a requirement as below I have to change env twice like: cadenv <env> cadenv <env> ccm start -d /dbpath ccm tar -xvf *.tar ccm rcv .... mv *.tar BACKUP but after I do the first cadenv <env> , I am unable to execute any of the later commands . ... (6 Replies)
Discussion started by: charlei
6 Replies

6. Shell Programming and Scripting

simple shell - how to get a parameter typed in a shell script

Hi, I am new to unix and using linux 7.2. I would like to create a script that would make it easyer for me to run my java programms. At the moment I have to type java myJavaprogram I am trying to write a script that will allow me to type something like this "myscript myJavaprogram" or maybe... (4 Replies)
Discussion started by: cmitulescu
4 Replies

7. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

8. Shell Programming and Scripting

Any shell or hack that makes the shell command line take vi commands?

basically i'm tired of hitting the left arrow a few dozen times when correcting a mistake or modifying a history command i'd like to use vim style key shortcuts while on the command line so that a 55 moves the cursor 55 places to the left... and i want all the other vi goodies, search of... (3 Replies)
Discussion started by: marqul
3 Replies

9. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies

10. Shell Programming and Scripting

Pass C shell array to another C shell script(csh) and shell(sh)

Dear Friends, Please help me on this my script name is send.csh In this i have written the statement like this set args = ( city state country price ) I want to pass this array to another c shell called receiver.csh. and i want to use it in this c shell or how to pass to... (2 Replies)
Discussion started by: SA_Palani
2 Replies
gdcmconv(1)							       GDCM							       gdcmconv(1)

NAME
gdcmconv - Tool to convert DICOM to DICOM. SYNOPSIS
gdcmconv [options] file-in file-out DESCRIPTION
The gdcmconv command line program takes as input a DICOM file (file-in) and process it to generate an output DICOM file (file-out). The command line option dictate the type of operation(s) gdcmconv will use to generate the output file. PARAMETERS
file-in DICOM input filename file-out DICOM output filename options PARAMETERS -i --input DICOM filename -o --output DICOM filename options -X --explicit Change Transfer Syntax to explicit. -M --implicit Change Transfer Syntax to implicit. -U --use-dict Use dict for VR (only public by default). --with-private-dict Use private dict for VR (advanced user only). -C --check-meta Check File Meta Information (advanced user only). --root-uid Root UID. --remove-gl Remove group length (deprecated in DICOM 2008). --remove-private-tags Remove private tags. --remove-retired Remove retired tags. image options -l --apply-lut Apply LUT (non-standard, advanced user only). -P --photometric-interpretation %s Change Photometric Interpretation (when possible). -w --raw Decompress image. -d --deflated Compress using deflated (gzip). -J --jpeg Compress image in jpeg. -K --j2k Compress image in j2k. -L --jpegls Compress image in jpeg-ls. -R --rle Compress image in rle (lossless only). -F --force Force decompression/merging before recompression/splitting. --compress-icon Decide whether icon follows main TransferSyntax or remains uncompressed. --planar-configuration [01] Change planar configuration. -Y --lossy Use the lossy (if possible) compressor. -S --split %d Write 2D image with multiple fragments (using max size) JPEG options -q --quality %*f set quality. JPEG-LS options -e --lossy-error %*i set error. J2K options -r --rate %*f set rate. -q --quality %*f set quality. -t --tile %d,%d set tile size. -n --number-resolution %d set number of resolution. --irreversible set irreversible. general options -h --help print this help text and exit -v --version print version information and exit -V --verbose verbose mode (warning+error). -W --warning warning mode, print warning information -E --error error mode, print error information -D --debug debug mode, print debug information special options -I --ignore-errors convert even if file is corrupted (advanced users only, see disclaimers). environment variable GDCM_ROOT_UID Root UID Simple usage gdcmconv is a great tool to convert broken DICOM implementation into properly parsable DICOM file. Usage is simply: $ gdcmconv input.dcm output.dcm or if you prefer being explicit: $ gdcmconv -i input.dcm -o output.dcm Even though gdcmconv can overwrite directly on the same file (input.dcm = output.dcm), it is recommended that user should first convert into a different file to make sure the bug is properly handled by GDCM. Typical cases where you would want to use gdcmconv in its simple form: o convert non-cp246 conforming file into conforming cp246, o convert implicit little endian transfer syntax file meta header into proper explicit little endian transfer syntax, o convert the GE-13 bytes bug, o convert dual syntax file: implicit/explicit, o convert Philips dual Little Endian/Big Endian file, o convert GDCM 1.2.0 broken UN-2-bytes fields, o &... o All other broken files listed in the supported section. When no option other is used, only the dataset is inspected. So encapsulated Pixel Data, for instance, is not inspected for well known bugs. When doing this kind of work, this is usually a good idea to perform some kind of quality control, see gdcmconv Quality Control section (down below). Typical usage File Meta Header Running $ gdcmconv input.dcm output.dcm Is not enough to recompute file meta header, when input file is buggy. You may want to use: --check-meta $ gdcmconv --check-meta input.dcm output.dcm See typical cases such as: GE_DLX-8-MONO2-PrivateSyntax.dcm or PICKER-16-MONO2-No_DicomV3_Preamble.dcm from gdcmData. Conversion to Explicit Transfer Syntax To convert a file that was written using Implicit Transfer Syntax into Explicit Transfer Syntax simply use: $ gdcmconv --explicit uncompressed.dcm compressed.dcm Compressing to lossless JPEG To compress an uncompressed DICOM file to a JPEG Lossless encapsulated format: $ gdcmconv --jpeg uncompressed.dcm compressed.dcm Compressing to lossy JPEG To compress an uncompressed DICOM file to a JPEG Lossy encapsulated format: $ gdcmconv --lossy --jpeg -q 90 uncompressed.dcm compressed.dcm Note: -q is just one of the many way to specify lossy quality, you need to inspect the other cmd line flag to specify lossyness properties. Compressing to lossless JPEG-LS To compress an uncompressed DICOM file to a JPEG-LS Lossless encapsulated format: $ gdcmconv --jpegls uncompressed.dcm compressed.dcm Compressing to lossy JPEG-LS To compress an uncompressed DICOM file to a JPEG-LS Lossy encapsulated format: $ gdcmconv --lossy --jpegls -e 2 uncompressed.dcm lossy_compressed.dcm Note: -e (or --lossy-error) means that the maximum tolerate error is 2 for each pixel value Compressing to lossless J2K To compress an uncompressed DICOM file to a JPEG-2000 Lossless encapsulated format: $ gdcmconv --j2k uncompressed.dcm compressed.dcm Compressing to lossy J2K To compress an uncompressed DICOM file to a JPEG-2000 Lossy encapsulated format: $ gdcmconv --lossy -q 55,50,45 --j2k uncompressed.dcm lossy_compressed.dcm Note: -q is just one of the many way to specify lossy quality, you need to inspect the other cmd line flag to specify lossyness properties. Compressing to lossless RLE To compress an uncompressed DICOM file to a RLE Lossless encapsulated format: $ gdcmconv --rle uncompressed.dcm compressed.dcm There is no such thing as lossy RLE compression. Forcing (re)compression Sometime it is necessary to use the --force option. By default when user specify --j2k and input file is already in JPEG 2000 encapsulated DICOM format then no operation takes places. By using --force you make sure that (re)compression operation takes places. Real life example of why you would use --force: o When Pixel Data is missing data / is padded with junk o When you would like to make sure GDCM can handle decompression & recompression cycle Decompressing a Compressed DICOM $ gdcmconv --raw compressed.dcm uncompressed.dcm Compressing an uncompressed Icon By default when compressing a DICOM Image file, gdcmconv will not compress the icon. A user option needs to be turned on to explicitely force the compression of the Icon Image Sequence Pixel Data For example, by default we will not compress the Icon Image Sequence Pixel Data attribute: $ gdcmconv --jpeg gdcmData/simpleImageWithIcon.dcm uncompressed_icon.dcm In the following example we will explicitely compress the Icon Image Sequence Pixel Data attibute. In that case the same Transfer Syntax is being used for both the main Pixel Data and the Pixel Data from the Icon Image Sequence: $ gdcmconv --jpeg --compress-icon gdcmData/simpleImageWithIcon.dcm compressed_icon.dcm Generating an Icon For some application it might be necessary to produce a small preview of the main image to be able to quickly load that short preview instead of the main image. In that case: gdcmconv --raw --generate-icon gdcmData/test.acr test_icon.dcm In some cases the main Pixel Data element is expressed as pixel defined on 16bits. Since Icon can only store at most pixel of size 8bits, a rescale operation needs to take place. In order to properly select a better interval for doing the rescale operation user can specify the min max used for the rescale operation: gdcmconv --raw --generate-icon --icon-minmax 0,192 gdcmData/012345.002.050.dcm icon_minmax.dcm Changing the planar Configuration Often RLE files are compressed using a different Planar Comnfiguration (RRR ... GGG... BBB...) instead of the usual triplet (RGB ... RGB ... RGB ). So upon decompression the Planar Configuration is 1. This is perfectly legal in DICOM, however this is unconventional, and thus it may be a good idea to also change the planar configuration and set it to the default : $ gdcmconv --raw --planar-configuration 0 compressed.dcm uncompressed1.dcm To reinvert the planar configuration of file 'uncompressed1.dcm', simply do: $ gdcmconv --raw --planar-configuration 1 uncompressed1.dcm uncompressed2.dcm Lossless Conversion When talking about lossless conversion, there is an ambiguity that need to be understood. To achieve higher compression ratio, the RGB color space is usually not used, in favor of a YBR one. Changing from one color space to the other is (bit level) not lossless. For more detail, see what are the true lossless transformations as described: http://sourceforge.net/apps/mediawiki/gdcm/index.php?title=Color_Space_Transformations Quality Control One important part when using gdcmconv it to have a way to quality control the output. You can use 3rd party tool to check the output of gdcmconv is correct. DCMTK / dicom3tools Using another DICOM implementation such as the one from DCMTK or dicom3tools can be a good process to check the output of gdcmconv. o For DCMTK use: dcmdump o For dicom3tools use: dcdump For reference, gdcmconv --raw will act as dcmdjpeg +cn +px, since it never tries to convert color space. VIM: vimdiff You can setup your favorite editor to compare the output, for instance in vim: autocmd BufReadPre *.dcm set ro autocmd BufReadPost *.dcm silent %!dcmdump -M +uc '%' then simply do: $ vimdiff input.dcm output.dcm vbindiff On UNIX you can visually compare binary file using the vbindiff command: $ vbindiff input.dcm output.dcm SEE ALSO
gdcmdump(1), gdcmraw(1), gdcminfo(1) COPYRIGHT
Copyright (c) 2006-2011 Mathieu Malaterre Version 2.2.0 Tue Feb 5 2013 gdcmconv(1)
All times are GMT -4. The time now is 06:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy