Skip to content

Commit

Permalink
Merge pull request #448 from jonclayden/underscore-compression-order
Browse files Browse the repository at this point in the history
Remove redundant underscores before creating subdirectories
  • Loading branch information
neurolabusc authored Nov 17, 2020
2 parents 1e20c4e + cb99487 commit eaa78f8
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions console/nii_dicom_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2714,6 +2714,18 @@ int nii_createFilename(struct TDICOMdata dcm, char * niiFilename, struct TDCMopt
appendChar[0] = kPathSeparator;
if ((strlen(pth) > 0) && (pth[strlen(pth)-1] != kPathSeparator) && (outname[0] != kPathSeparator))
strcat (baseoutname,appendChar);

//remove redundant underscores
int len = strlen(outname);
int outpos = 0;
for (int inpos = 0; inpos < len; inpos ++) {
if ((outpos > 0) && (outname[inpos] == '_') && (outname[outpos-1] == '_'))
continue;
outname[outpos] = outname[inpos];
outpos++;
}
outname[outpos] = 0;

//Allow user to specify new folders, e.g. "-f dir/%p" or "-f %s/%p/%m"
// These folders are created if they do not exist
char *sep = strchr(outname, kPathSeparator);
Expand Down Expand Up @@ -2741,16 +2753,6 @@ int nii_createFilename(struct TDICOMdata dcm, char * niiFilename, struct TDCMopt
strcat (newdir,ch);
}
}
//remove redundant underscores
int len = strlen(outname);
int outpos = 0;
for (int inpos = 0; inpos < len; inpos ++) {
if ((outpos > 0) && (outname[inpos] == '_') && (outname[outpos-1] == '_'))
continue;
outname[outpos] = outname[inpos];
outpos++;
}
outname[outpos] = 0;
//printMessage("path='%s' name='%s'\n", pathoutname, outname);
//make sure outname is unique
strcat (baseoutname,outname);
Expand Down

0 comments on commit eaa78f8

Please sign in to comment.