I need to parse a file name and move the file to a folder based on part of the file name.
Lets say I have several files in a folder C:\SYSLOG\Servers and Firewall\Logs. They are log files from several different servers or devices.. I need to move them to our NAS for archival. Sample file names:
Boston.North.Application.S01.120613.log
Boston.South.Application.S12.122513.log
Lexington.System.S02.073013.log
Lexington.System.S22.073013.log
Madison.IPS.S01.050414.txt
I need to move them to a corresponding folder on the NAS. My folder structure looks like this:
\\NAS\Logs\Boston North Application
\\NAS\Logs\Boston South Application
\\NAS\Logs\Lexington System
\\NAS\Logs\Madison IPS
So basically I am wanting to parse the file name for everything to the left of the server (Sxx), and replace the . with spaces to create the destination folder name.
The files are not always .log files. All files have a .Sxx in the name and xx will always be numbers. If destination folder does not exist, then skip the file. There are no subfolders in C:\SYSLOG\Servers and Firewall\Logs.
I think I am trying to do something similar to powershell to move files based on part of file name