pnlbwh / CNN-Diffusion-MRIBrain-Segmentation

CNN based brain masking
Other
14 stars 10 forks source link

File exists error in mv #16

Closed tashrifbillah closed 4 years ago

tashrifbillah commented 4 years ago

Hi @SenthilCaesar , https://github.com/pnlbwh/CNN-Diffusion-MRIBrain-Segmentation/blob/remove-ext-dep/pipeline/dwi_masking.py#L516

generates the following error when previous slicesdir_multi exists:

mv: cannot move ‘connectom/A/slicesdir’ to ‘connectom/A/slicesdir_multi/slicesdir’: File exists

The reason being, mv does not copy the content of slicesdir, rather moves the slicesdir folder to slicesdir_multi. If previous output exists, then mv fails. See the following simple example:

[tb571@pnl-z840-2 A]$ mkdir top
[tb571@pnl-z840-2 A]$ mkdir top/top-1
[tb571@pnl-z840-2 A]$ touch top/top-1/abc.txt
[tb571@pnl-z840-2 A]$ tree top
top
└── top-1
    └── abc.txt

[tb571@pnl-z840-2 A]$ mkdir top-1
[tb571@pnl-z840-2 A]$ touch top-1/abc.txt
[tb571@pnl-z840-2 A]$ tree top
top-1
└── abc.txt

[tb571@pnl-z840-2 A]$ mv top-1 top
mv: cannot move ‘top-1/’ to ‘top/top-1’: File exists

I shall give you a solution for this.