Error when using a bash loop

GROMACS version: 2022.4
GROMACS modification: No

Hi,

I am trying to use gromacs through a bash loop to automatically run through all my folders and sub-folders; and rename the output with the same of the folders and sub-folders.

I have used this script on an external computer cluster through a Job.sh file and it worked as expected; but when running it on my own computer I get a strange error.

It will go into all the folders but for some (not always the same ones when repeating the same script) it will not recognise the -o command from the trjconv.

This is the script I use:

#!/bin/bash
for name in $(ls -d */)
do
cd $name
for sub in $(ls -d */)
do
cd $sub
for third in $(ls -d */)
do
cd $third
echo 5 | gmx trjconv -s md_0_1.tpr -f md_0_1_noPBC.xtc -o Backbone.xtc
mv Backbone.xtc $(basename "$(dirname "$(dirname "$(dirname "/$name/$sub/$third/Backbone.xtc")")")")_$(basename "$(dirname "$(dirname "/$name/$sub/$third/Backbone.xtc")")")_$(basename "$(dirname "/$name/$sub/$third/Backbone.xtc")")_$(basename "/$name/$sub/$third/Backbone.xtc")
mv $(basename "$(dirname "$(dirname "$(dirname "/$name/$sub/$third/Backbone.xtc")")")")_$(basename "$(dirname "$(dirname "/$name/$sub/$third/Backbone.xtc")")")_$(basename "$(dirname "/$name/$sub/$third/Backbone.xtc")")_$(basename "/$name/$sub/$third/Backbone.xtc") /mnt/e/Same_Start
cd ..
done
cd ..
done
cd ..
done

And the error I get for some sub-folders but not all of them:

Program: gmx trjconv, version 2022.4
Source file: src/gromacs/utility/futil.cpp (line 427)

File input/output error:
Backbone.xtc

For more info (etc)"

I am really not sure why it works in some folders and not in others (on my computer anyway; when it ran fine on the external clusters).

Any ideas ?

Update:
When I manually entered the gmx trjconv command into the directory directly it still wouldn’t allow the output filename to be Backbone.xtc; BUT when changed to anything other than that it works fine !