Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Finding and renaming files with exceptions Post 302970467 by azurite on Wednesday 6th of April 2016 09:47:37 PM
Old 04-06-2016
Hello,

Wow! Thank you for taking the time to write great explanations! I have printed it out and will re-read everything to really understand it.

Instead of creating new threads, is it okay if I keep posting new questions in this thread?

If so, I have a question on creating variables. I have tried to research and come up with a solution (to the text quoted below) on my own but I do not know if I am on the right track. If possible could you tell me if I am moving in the right direction?

Quote:
So as far as trying to distinguish between "100_eddy_corrected_brain.nii.gz" and "100_eddy_corrected_brain_mask.nii.gz" if you could define the first as a variable, say $eddy_file or something of the sort, you could pipe it through to a cut command defining a period as your delimiter and take everything in front of it, so something like:
{echo $eddy_file | cut -d. -f1}_mask.nii.gz

But that would depend on using the "set" command to create the variable.
I have come up with the following: though I am not sure what is meant by using the 'set' command.

Code:
#/bin/bash
eddy_file=`cat eddy_corrected_brain.txt`
echo $eddy_file

The eddy_corrected_brain.txt is a text file with pathnames of all the files that match eddy_corrected_brain.nii.gz from the initial find command/results.

Thank you again!
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

finding duplicate files by size and finding pattern matching and its count

Hi, I have a challenging task,in which i have to find the duplicate files by its name and size,then i need to take anyone of the file.Then i need to open the file and find for more than one pattern and count of that pattern. Note:These are the samples of two files,but i can have more... (2 Replies)
Discussion started by: jerome Sukumar
2 Replies

2. Shell Programming and Scripting

Renaming the files

Hello, i wanna rename my files which names are written in movies.txt films.txt = amovie bmovie cmovie dmovie emovie and i wanna find this files and rename the files to 1_amovie ... (12 Replies)
Discussion started by: redbeard_06
12 Replies

3. Shell Programming and Scripting

renaming files, please help

I want to rename the files by taking part of the file and appending date to it. please help e.g. abc-390.csv xyz-908.csv desired format is abc_YYYYMMDD.csv This is what I have but it is not working for each in *.csv; do mv $each /abc/data/"`date '+test_%Y%M%M'`".csv done (2 Replies)
Discussion started by: mqasim
2 Replies

4. Shell Programming and Scripting

Finding files older than the current date and time and renaming and moving

Hi, I have a very urgent requirement here. I have to find all files in the specified directory but not in the sub directories(The directory name is stored in a variable) which are older than the current date as well as current time and rename it as filename_yyyymmddhhmmss.ext and move it into a... (7 Replies)
Discussion started by: ragavhere
7 Replies

5. Shell Programming and Scripting

renaming files

Hello, I wanted to rename one file where filename contains space.. How can i rename in unix? The file name is ABC XYZ.TXT I wanted to rename this file as ABCXYZ.TXT. Any help is greatly appreciated... Regards. (4 Replies)
Discussion started by: govindts
4 Replies

6. Shell Programming and Scripting

renaming files or adding a name in the beginning of all files in a folder

Hi All I have a folder that contains hundreds of file with a names 3.msa 4.msa 21.msa 6.msa 345.msa 456.msa 98.msa ... ... ... I need rename each of this file by adding "core_" in the begiining of each file such as core_3.msa core_4.msa core_21.msa (4 Replies)
Discussion started by: Lucky Ali
4 Replies

7. Shell Programming and Scripting

Renaming files

Hi i have to achieve the following i have files as xyz001.csv, xyz002.csv.......xyz0025.csv in a folder, i need to keep xyz001.csv as it is but want to remove the extra zero on filename from 10 say xyz0010 should be renamed to xyz010 xyz0025 should be renamed as xyz025 Note xyz... (8 Replies)
Discussion started by: mad_man12
8 Replies

8. Shell Programming and Scripting

Renaming files

Hello, I am looking for a command line that will rename name files : f700_abc_o_t_MASTERID_AS_AE_20130323.csv like this f700_abc_o_t_MASTERID_AS_AE_20130324.csv The great idea could be to get the date stamp 20130323 and change any part of it, instead of just change the... (4 Replies)
Discussion started by: Aswex
4 Replies

9. Shell Programming and Scripting

Renaming multiple files in sftp server in a get files script

Hi, In sftp script to get files, I have to rename all the files which I am picking. Rename command does not work here. Is there any way to do this? I am using #!/bin/ksh For eg: sftp user@host <<EOF cd /path get *.txt rename *.txt *.txt.done ... (7 Replies)
Discussion started by: jhilmil
7 Replies
IMAGEMATH(1)							   User Commands						      IMAGEMATH(1)

NAME
ImageMath - part of ANTS registration suite DESCRIPTION
Usage: ./ImageMath ImageDimension OutputImage.ext Operator Image1.ext Image2.extOrFloat some options output text files The last two arguments can be an image or float value Valid Operators : m (multiply) , + (add) , - (subtract) , / (divide) , ^ (power) , exp -- take exponent exp(imagevalue*value) addtozero overadd abs total -- sums up values in an image or in image1*image2 (img2 is the probability mask) Decision -- computes result=1./(1.+exp(-1.0*( pix1-0.25)/pix2)) Neg (Produce Image Negative ) , G Image1.ext s (Smooth with Gaussian of sigma = s ) MD Image1.ext s ( Morphological Dilation with radius s ) , ME Image1.ext s ( Morphological Erosion with radius s ) , MO Image1.ext s ( Morphological Opening with radius s ) MC Image1.ext ( Morphological Closing with radius s ) GD Image1.ext s ( Grayscale Dilation with radius s ) , GE Image1.ext s ( Grayscale Erosion with radius s ) , GO Image1.ext s ( Grayscale Opening with radius s ) GC Image1.ext ( Grayscale Closing with radius s ) D (DistanceTransform) , Segment Image1.ext N-Classes LocalityVsGlobalityWeight-In-ZeroToOneRange OptionalPriorImages ( Segment an Image with option of Priors , weight 1 => maximally local/prior-based ) Grad Image.ext S ( Gradient magnitude with sigma s -- if normalize, then output in range [0, 1] ) , Laplacian Image.ext S normalize? ( laplacian computed with sigma s -- if normalize, then output in range [0, 1] ) , Normalize image.ext opt ( Normalize to [0,1] option instead divides by average value ) PH (Print Header) , Byte ( Convert to Byte image in [0,255] ) LabelStats labelimage.ext valueimage.nii ( compute volumes / masses of objects in a label image -- write to text file ) ROIStatistics LabelNames.txt labelimage.ext valueimage.nii ( see the code ) DiceAndMinDistSum LabelImage1.ext LabelImage2.ext OptionalDistImage -- outputs DiceAndMinDistSum and Dice Overlap to text log file + optional dis- tance image Lipschitz VectorFieldName -- prints to cout & writes to image InvId VectorFieldName VectorFieldName -- prints to cout & writes to image GetLargestComponent InputImage {MinObjectSize} -- get largest object in image ThresholdAtMean Image %ofMean FlattenImage Image %ofMax -- replaces values greater than %ofMax*Max to the value %ofMax*Max stack Image1.nii.gz Image2.nii.gz --- will put these 2 images in the same volume CorruptImage Image NoiseLevel Smoothing TileImages NumColumns ImageList* RemoveLabelInterfaces ImageIn EnumerateLabelInterfaces ImageIn ColoredImageOutname NeighborFractionToIgnore FitSphere GM-ImageIn {WM-Image} {MaxRad-Default=5} HistogramMatch SourceImage ReferenceImage {NumberBins-Default=255} {Number- Points-Default=64} PadImage ImageIn Pad-Number ( if Pad-Number is negative, de-Padding occurs ) Where Image ValueToLookFor maskIm- age-option tolerance --- the where function from IDL TensorFA DTImage TensorColor DTImage --- produces RGB values identifying prin- cipal directions TensorToVector DTImage WhichVec --- produces vector field identifying one of the principal directions, 2 = largest eigenvalue TensorToVectorComponent DTImage WhichVec --- 0 => 2 produces component of the principal vector field , i.e. largest ei- genvalue. 3 = 8 => gets values from the tensor TensorIOTest DTImage --- will write the DT image back out ... tests I/O processes for consistency. MakeImage SizeX SizeY {SizeZ} SetOrGetPixel ImageIn Get/Set-Value IndexX IndexY {IndexZ} -- for example ImageMath 2 outimage.nii SetOrGetPixel Image Get 24 34 -- gets the value at 24, 34 ImageMath 2 outimage.nii SetOrGetPixel Image 1.e9 24 34 -- this sets 1.e9 as the value at 23 34 you can also pass a boolean at the end to force the physical space to be used TensorMeanDiffusion DTImage CompareHeadersAndImages Image1 Image2 --- tries to find and fix header error! output is the repaired image with new header. never use this if you trust your header information. CountVoxelDifference Image1 Image2 Mask --- the where function from IDL stack image1 image2 --- stack image2 onto image1 CorrelationUpdate Image1 Image2 RegionRadius --- in voxels , Compute update that makes Image2 more like Image1 ConvertImageToFile imagevalues.nii {Optional-ImageMask.nii} -- will write voxel values to a file PValueImage TValueImage dof ConvertToGaussian TValueImage sigma-float ConvertImageSetToMatrix rowcoloption Mask.nii *images.nii -- each row/column contains image content extracted from mask applied to images in *img.nii ConvertVector- ToImage Mask.nii vector.nii -- the vector contains image content extracted from a mask - here we return the vector to its spatial origins as image content TriPlanarView ImageIn.nii.gz PercentageToClampLowIntensity PercentageToClampHiIntensity x-slice y-slice z-slice TruncateImageIntensity inputImage {lowerQuantile=0.05} {upperQuantile=0.95} {numberOfBins=65} {binary-maskImage} Fill- Holes Image parameter : parameter = ratio of edge at object to edge at background = 1 is a definite hole bounded by object only, 0.99 is close -- default of parameter > 1 will fill all holes PropagateLabelsThroughMask speed/binaryimagemask.nii.gz initiallabelimage.nii.gz Optional-Stopping-Value -- final output is the propagated label image optional stopping value -- higher values allow more distant propagation FastMarchingSegmentation speed/binaryimagemask.nii.gz initiallabelimage.nii.gz Optional-Stopping-Value -- final output is the propagated label image optional stopping value -- higher values allow more distant propagation ExtractSlice volume.nii.gz slicetoextract --- will extract slice number from last dimension of volume (2,3,4) dimensions ConvertLandmarkFile InFile.txt ---- will convert landmark file between formats. see ants.pdf for description of formats. e.g. ImageMath 3 outfile.vtk ConvertLandmarkFile infile.txt ImageMath 1.9 May 2012 IMAGEMATH(1)
All times are GMT -4. The time now is 05:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy