Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

How Can I Move Files Based on Values in the File Name?

$
0
0

So I have came across this a few time now and I can not figure out a way of resolving this.

Problem:

I have a bunch of file and I need to move based on the file name. 

Current file location:

C:\servername\filename

 

File names: (servername_logtype_yyyymmdd)

server1_log_20150111

server2_log_20150111

server1_report_20150111

server2_report_20150111

 

New file location: (C:\YYYY\MM\servertype\servername\file)

C:\2015\Jan\windows\server1\server1_log_20150111

C:\2015\Jan\linux\server2\server2_log_20150111

C:\2015\Jan\windows\server1\server1_report_20150111

C:\2015\Jan\linux\server2\server2_report_20150111

 

Any help with figuring this out would be great!

I have found this but it isn't what i really looking for.

http://blogs.technet.com/b/heyscriptingguy/archive/2007/10/24/hey-scripting-guy-how-can-i-move-files-based-on-a-value-in-the-file-name.aspx

 

Thanks.


Viewing all articles
Browse latest Browse all 6937

Trending Articles