Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Moving folders (including files) based to folder name

Reply
 
Old 07-23-2008   #1 (permalink)
gogram


 
 

Moving folders (including files) based to folder name

Hi,
I am trying to move some 2007 data which is stored in the following
folder naming format:
01-Aug-2007
to a central Archive2007 folder.
I have the following script:

dir "v:\UXP VRC" | Where-Object { $_.Name -like "*-*-2007" } | Move-
Item -Destination v:\Archive2007

but I get the following error when running the script:

WARNING: Access to the path 'V:\UXP VRC\11-Oct-2007' is denied.
(This appears for all folders)

I can drag and drop without any issues.
Thanks in advance.
Giles Ogram

My System SpecsSystem Spec
Old 07-23-2008   #2 (permalink)
Shay Levy [MVP]


 
 

Re: Moving folders (including files) based to folder name



Adding to Marco, try to add -force. I would test it first on a test folder,
make a copy of one directory and try
to move that directory only with the -force parameter, there may be some
read only files inside.

BTW, you can make it shorter:

move-item "v:\UXP VRC\*-*-2007" -dest v:\Archive2007 -force



---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic


Quote:

> Hi,
> I am trying to move some 2007 data which is stored in the following
> folder naming format:
> 01-Aug-2007
> to a central Archive2007 folder.
> I have the following script:
> dir "v:\UXP VRC" | Where-Object { $_.Name -like "*-*-2007" } | Move-
> Item -Destination v:\Archive2007
>
> but I get the following error when running the script:
>
> WARNING: Access to the path 'V:\UXP VRC\11-Oct-2007' is denied. (This
> appears for all folders)
>
> I can drag and drop without any issues.
> Thanks in advance.
> Giles Ogram

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Moving files from one directory to another based on the file namecontains specified string by using vbscript VB Script
vista leaves behind folders when moving folders with files in them Vista General
Re: Moving files based on filesize PowerShell
Deleteing Files in a folder based on date! Vista file management
When moving folders original folder is not deleted Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46