Script for moving series of sub folders

Hello, I'm new to this forum. Did a search but I didn't quite find what I was looking for. This is probably a fairly easy request but I'm just not sure how to accomplish this.

I have a folder structure that looks something like this:

/names/company1/archive
/names/company1/newarchive

/names/company2/archive
/names/company2/newarchive

/names/company3/archive
/names/company3/newarchive

There are tons of companies under the /names folder. I want to start at the /names folder and search for any folders under the company/archive folder and move those folders to the same companies company/newarchive folder.

Thanks!

Will this be exhaustive, i.e. will all files/folders be moved and none remain? Then just rename /.../.../archive to /.../.../newarchive.

I thought about the renaming process but the folder structures already exist and there are some that already are in place. i.e. already have the folders in the correct spot. So I really don't want to blanket rename the entire folder structure. Both the archive and newarchive folders will need to remain after the move.

---------- Post updated at 02:39 PM ---------- Previous update was at 01:03 PM ----------

I forgot to also mention that there are files within the folders I want to move.

How about this solution using rsync.

The find command is to remove empty directories left under the company/archive directory, I'm not sure if you wanted those cleaned up or not.

cd /names

for arch in */archive
do
   newarch="${arch%archive}newarchive"
   if [ -d "$newarch" ]
   then
       rsync -a --remove-source-files "$arch" "$newarch"
       find "$arch" -mindepth 1 -type d -delete
   fi
done

Chubler_XL,

Thank you for the suggestion! That worked great other than one small issue....it takes the archive folder itself and all of its contents and places them under the newarchive folder.

IE:
before the move
/names/company1/archive/<a bunch of subfolders>
/names/company1/newarchive/

after the move
/names/company1/archive/
/names/company1/newarchive/archive/<a bunch of subfolders>

I need it to take the contents of the archive folder and move them to the newarchive folder.

IE:
before the move
/names/company1/archive/<a bunch of subfolders>
/names/company1/newarchive/

after the move
/names/company1/archive
/names/company1/newarchive/<a bunch of subfolders>

Thank you!

---------- Post updated at 09:27 AM ---------- Previous update was at 08:12 AM ----------

BTW, I fixed the issue I pointed out by making these simple changes:

#!/bin/bash
for arch in */archive/*
do
   newarch="${arch%archive/*}archivenew"
   if [ -d "$newarch" ]
   then
      rsync -a --remove-source-files "$arch" "$newarch"
      find "$arch" -mindepth 0 -type d -delete
   fi
done