Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Parse, Copy, Move files and Log results

$
0
0

I'm looking for a PS script to Parse, Copy, Move and Log results of Files in a directory that I will schedule to run as a task.

I am currently teaching myself some basic PS scripting but am obviously not there quite yet. While I have been able to accomplish some basics below I seem to struggle with the search and parsing of files. And have not even gotten to the logging part.  I would be routinely updating modifying this a needs arouse.

Any suggestions or examples of how to accomplish this would be great.

Files may look like this in D:\dir1start

               File_123_xxxxxxxxxxxx.zip               Date Time Modified

               File_234_xxxxxxxxxxxx.zip               Date Time Modified

               File_345_xxxxxxxxxxxx.zip               Date Time Modified

     File_456_xxxxxxxxxxxx.zip               Date Time Modified

Directories

               D:\dir1start

               \\Server1\dir

               \\Server2\dir

               \\Server3\dir        etc. etc.

               D:\dir1Archived

Logs

               D:\Logs\FileCopy_DATE_TIME.log

(csv formatted log of files copied, moved, path     success or failure)

Script would

  1. Look for in D:\dir1start  for “File_123_xxx.zip”           [newer than 1 hour]
    copy to \\server1\dir         and         \\Server2\dir
      
  2. Look for in D:\dir1start  for “File_234_xxx.zip”           [newer than 1 hour]
    copy to \\server1\dir         and         \\Server2\dir       and         \\server3\dir

  3. Look for in D:\dir1start  for “File_345_xxx.zip”           [newer than 1 hour]
    copy to \\server1\dir         and         \\server3\dir

  4. Look for in D:\dir1start  for “File_456_xxx.zip”           [newer than 1 hour]
    copy to \\Server2\dir         and         \\server3\dir

  5. Look for ALL File dates [Older than 30days min] move to D:\dir1Archive

  6. Verbose Log and output results in csv to D:\Logs\FileCopy_DATE_TIME.log

Thanks



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>