jeffharbert

Move oldest file to different folder

Feb 28th, 2018
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Change the -Include file extension to whatever you need.
  2. # This example uses .jpg
  3. # To ignore file extensions, use this syntax on the first line:
  4. # Get-ChildItem -Path c:\path\to\source\folder\* |
  5.  
  6. Get-ChildItem -Path c:\path\to\source\folder\* -Include *.jpg |
  7. Sort-Object CreationTime |
  8. Select-Object -First 1 |
  9. Move-Item -Destination c:\path\to\destination\folder
Advertisement
Add Comment
Please, Sign In to add comment