Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant underscores before creating subdirectories #448

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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