Move directories in script.sh doesn't work

Dear All,
I would like move some directories in another location.
Basically, my

ls -l

is

drwxr-xr-x 3 XXXXXXXXXXXXXXXXXXXX      4096 Feb 24 02:18 data.N701_N502.ABCDE
-rw-r--r-- 1 XXXXXXXXXXXXXXXXXXXX 185865797 Feb 23 11:27 data.N701_N502.ABCDE_file1
-rw-r--r-- 1 XXXXXXXXXXXXXXXXXXXX 185363492 Feb 23 11:27 data.N701_N502.ABCDE_file2
drwxr-xr-x 3 XXXXXXXXXXXXXXXXXXXX      4096 Feb 24 07:56 data.N701_N503.ABCDE
-rw-r--r-- 1 XXXXXXXXXXXXXXXXXXXX 736833701 Feb 23 11:45 data.N701_N503.ABCDE_file1
-rw-r--r-- 1 XXXXXXXXXXXXXXXXXXXX 724991500 Feb 23 11:45 data.N701_N503.ABCDE_file2
drwxr-xr-x 3 XXXXXXXXXXXXXXXXXXXX      4096 Feb 24 03:39 data.N701_N504.ABCDE
-rw-r--r-- 1 XXXXXXXXXXXXXXXXXXXX 303580046 Feb 23 11:32 data.N701_N504.ABCDE_file1
-rw-r--r-- 1 XXXXXXXXXXXXXXXXXXXX 333659372 Feb 23 11:32 data.N701_N504.ABCDE_file2
drwxr-xr-x 3 XXXXXXXXXXXXXXXXXXXX      4096 Feb 24 05:33 data.N701_N517.ABCDE
-rw-r--r-- 1 XXXXXXXXXXXXXXXXXXXX 382565401 Feb 23 11:35 data.N701_N517.ABCDE_file1
-rw-r--r-- 1 XXXXXXXXXXXXXXXXXXXX 396051949 Feb 23 11:35 data.N701_N517.ABCDE_file2

The directories as you can see have the same name of files (file1 and file2) except for the last part.

well, to move all directories I used this command, that work good:

for file in /PATH/!(*file*)
do mv $file /NEW/PATH/. &
done

This command work good when I run it in the terminal...

BUT

When I try to make a script.sh i have the following error message:

script.sh: line 15: syntax error near unexpected token `('
script.sh: line 15: `for file in /PATH/!(*file*)'

Well, actually I have not idea how to resolve this issue. I tried to modify the script but i get another error message (mv: cannot stat �data.N701_N502.ABCDE':No such file or directory) but is off topic!!!

terminal $SHELL=/bin/bash
script=#!/bin/bash
command=bash script.sh

Do you have any suggestion or explanation?

Best

Giuliano

PS: I am sorry for the title , I didn't know what to write!

Are you sure you're running the script in bash ? And, is the extglob option set in the subshell?

Ahhh, thank you!

That works!

Best

G