Question: How to move content of a folder to its subfolder.  

When I run this:

```
mv xyz/* xyz/archive

```

I get this notice:

> 
> mv: cannot move 'xyz/archive' to a subdirectory of itself,
> 'xyz/archive/archive'
> 
> 
> 

Is is possible to exclude `archive` folder from `xyz/*` selection ?

Answer: 
You can use [extended globs](https://www.gnu.org/software/bash/manual/bash.html#Pattern-Matching) to exclude archive from your pattern as follows:

```
shopt -s extglob
mv !(archive) archive

```

This will move everything in the current folder, except for hidden files, to archive.

If you want to move hidden files starting with a `.` to the `archive` folder too, you need to set the `dotglob` option as described in bash manual under [Filename Expansion](https://www.gnu.org/software/bash/manual/bash.html#index-pathname-expansion):

```
shopt -s dotglob

```

Here is another method using `find`:

```
find . -maxdepth 1 -type f ! -name "archive" -exec mv -t archive {} +

```

Although the first method is preferred, IMO, since bash builtins are perfectly capable of what `find` is doing here.
Yes, it is possible to exclude **archive** from the selection.

1. Enable the **extended globbing** option

```sh
shopt -s extglob

```

2. Run the following command that will move everything but **archive**

```sh
mv !(archive) archive

```

It will now move everything from xyz to archive

PS: I did run the **mv** command when I was inside the **xyz** folder.