How to move files and folders into a folder that is part of the same folder tree ?

Hello, I have the following code but i am getting access denied.

I need to move everything from "C:\ArchiveDocs\DocImageExports\Servicing" into "C:\ArchiveDocs\DocImageExports\Servicing\Old"

Move-Item -Path "C:\ArchiveDocs\DocImageExports\Servicing" -Destination "C:\ArchiveDocs\DocImageExports\Servicin
g\Old"

Open in new window


Error:
Move-Item : Access to the path 'C:\ArchiveDocs\DocImageExports\Servicing' is denied.

Open in new window


Thanks for your help
namergSystems AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aikimarkCommented:
With that statement, you are trying to move a folder into a sub-folder.  Do you really want to move all the files into the sub-folder?
0
namergSystems AdministratorAuthor Commented:
Yes. Into the sub-folder "Old"
0
mlmccCommented:
You can't move a folder into a subfolder.  You have to specify the files in the folder and move them into the subfolder.

mlmcc
0
Challenges in Government Cyber Security

Has cyber security been a challenge in your government organization? Are you looking to improve your government's network security? Learn more about how to improve your government organization's security by viewing our on-demand webinar!

aikimarkCommented:
Please test this:
Get-ChildItem -Path "C:\ArchiveDocs\DocImageExports\Servicing" | ? {$_.psiscontainer -eq $false} |
% {Move-Item -path $_.fullname -Destination "C:\ArchiveDocs\DocImageExports\Servicing\Old"}

Open in new window

0
namergSystems AdministratorAuthor Commented:
That script does not nothing. :(
0
namergSystems AdministratorAuthor Commented:
I got it.

This code did the trick.

Get-ChildItem -Path "C:\ArchiveDocs\DocImageExports\Servicing" | Where-Object {$_.Name -ne "Old"} | ForEach-Object {Move-Item -path $_.fullname -Destination "C:\ArchiveDocs\DocImageExports\Servicing\Old"}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
namergSystems AdministratorAuthor Commented:
The code did the requested question
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.