Click here to Skip to main content
15,939,960 members
Please Sign up or sign in to vote.
3.00/5 (3 votes)
See more:
I am currently looking for a script which would move the files from folders and subfolders from one location to another.

source: Network UNC path
Destination: Local server (where the script would run)


Below is the powershell script, which I had developed and its not working as per my requirement. The files in subfolders are not getting moved.

i am unable to customize it further....
get-childitem -Path "\\servername\location" |
    where-object {$_.LastWriteTime -lt (get-date).AddDays(-10)} | 
    move-item -destination "C:\Dumps"

Any further help is highly appreciated.
Posted
Updated 10-Sep-19 1:34am
v4

Add -Recurse option to get-childitem
 
Share this answer
 
Friends , need help to get the script. Powershell script to move files and folders with complete folder structure from one location to another older than x days

Get-ChildItem -Path C:\s -Recurse | Where-Object {$_.LastWriteTime -lt (Get-date).AddDays(0)} | Move-Item -destination C:\d

The script is working fine by moving the files,however need complete folder structure to be copied with the same name which is at source (c:\s),if the folder is empty needs to be moved completely at destination (c:\d)
 
Share this answer
 
Comments
CHill60 10-Sep-19 9:10am    
If you have a question of your own then use the red "Ask a Question" link at the top of this page. Do not post questions or comments as solutions to other members' problems

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900