I am trying to rename a directory in a bash script. I get the following error (file path has been substituted):
mv: can't rename 'some/path': No such file or directory
This is the code I am using:
if [ -d some/path ]; then
mv some/path other/path
fi
It makes no sense to make since I'm checking the existence of the directory beforehand. I also did a find . -print
to list all files and directories in the current working directory and the desired directory definitely exists. I know about case sensitivity and triple checked all paths. Any ideas why this is not working?
CodePudding user response:
The error message was misleading. Since the destination path did not exists the command failed with an error.
This change worked for me:
if [ -d some/path ]; then
mkdir -p other/path
mv some/path/* other/path
fi