[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2016-08-07
3
Medium Priority
?
32 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A procedure for exporting installed hotfix details of remote computers using powershell
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
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…

656 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