?
Solved

Powershell to move files with a "Date Modified" date more recent than 06/01/2016

Posted on 2016-08-07
3
Medium Priority
?
29 Views
Last Modified: 2016-08-07
Hi, this is actually a 2 part question, although I am sure the first one can be answered extremely easily.

1. How can I get a list of all files within a folder on a server? (I would like to know how to do this for one specific folder as well as for all sub-folders, with the output showing the directory that the file is in)

2. How can I move all .tif files within a folder that have a "Date Modified" date more recent than 06/01/2016 to a separate folder? This also is on a server.

Thanks!
0
Comment
Question by:Brent Guttmann
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 2000 total points
ID: 41746319
1a. Within a folder:
Get-ChildItem C:\Windows

Open in new window


1b. Within a folder and subfolders:
Get-ChildItem C:\Windows -Recurse

Open in new window


The most important command in PS:
Get-Help <Cmdlet>

2. Move the items; the Move-Item is in test mode and will only display what it would do, but not actually move anything. Remove the -WhatIf argument to run it for real.
$NewerThan = Get-Date -Date "06/01/2016"
Get-ChildItem C:\Temp -Filter *.tif -Recurse | ? {$_.LastWriteTime -ge $NewerThan} | Move-Item -Destination D:\Target -WhatIf

Open in new window

0
 
LVL 85

Expert Comment

by:oBdA
ID: 41746326
Oh, and in case you want the listing in table format, for example with LastWriteTime:
Get-ChildItem C:\Temp | Select FullName, LastWriteTime

Open in new window

And to write that to a file:
Get-ChildItem C:\Temp | Select FullName, LastWriteTime | Export-Csv C:\Temp\DirectoryList.csv -NoTypeInformation

Open in new window

To get a list of the properties you can select for an object, get an object of interest and pipe it to Get-Member:
Get-Item C:\Windows\notepad.exe | Get-Member

Open in new window

0
 

Author Comment

by:Brent Guttmann
ID: 41746353
Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question