Results 1 to 3 of 3
So, I need to find if, in a folder any directories exist, except a certain one named "mes croquis".
What I am trying to say, is that the re already ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 08-05-2010 #1Just Joined!
- Join Date
- Jan 2009
- Posts
- 6
[SOLVED] How to check if any directories exist, except a certain one ?
So, I need to find if, in a folder any directories exist, except a certain one named "mes croquis".
What I am trying to say, is that the re already is a directory named "my croquis", which I have to ignore. IF any other directory appears, I have to archive them.
I got everything so far, except the starting condition.
In other terms , I am lookign for something like this:
IF anyDir EXIST AND name != "mes croquis"
do something
else
exit
or
IF THE ONLY EXISTING DIR IS "mes croquis" then EXIT
I am kinda puzzled by this, I tried various combinations of [-d something ], find but nothing quite does it.
Any ideas ?
thanks in advance,
rmcb
- 08-05-2010 #2Just Joined!
- Join Date
- Jan 2009
- Posts
- 6
This is what I've got so far that is closest to something functional:
Nevertheless, it still does not work.Code:source="/home/roderick/Bureau/" anyDirs=`find $source* -maxdepth 1 -type d -not -name 'mes croquis'` if [ -n "$anyDirs" ]; then echo no dirs exit now else echo go ahead fi
- 08-05-2010 #3Just Joined!
- Join Date
- Jan 2009
- Posts
- 6
Ok, I got it working now:
Code:[ -s `find $source* -maxdepth 1 -type d -not -name 'mes croquis'` ] && exit



