saladoil
asked on
powershell script to search contents of file and move it to a different folder
I need a script to search the contents of a file and based on the title move to to a different folder - about 10 different possible values/folders. I think it can be done with the switch command but not much of a coder.
Thanks!
Thanks!
Could you attach some samples of the text files and specify what kind of values and titles are there!
ASKER
They are reports so on one of the top several lines have a title such as Analysis, Discounts or Notes so based on what the title is want to move the files to a Analysis folder, etc. Can't send samples as this is private data.
I got as far as using select-string -pattern "Notes" | copy-item etc but need to go through multiple files and send to different destinations.
Thanks
I got as far as using select-string -pattern "Notes" | copy-item etc but need to go through multiple files and send to different destinations.
Thanks
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
That doesn't seem to work - there are multiple reports and they aren't consistantly named Title: xxxx -
more like this:
REPORT - ARB015B AS OF 02/28/2011 RUN 03/05/2008
COMPANY - 3 . ANALYSIS OF ACCOUNTS RECEIVABLE PAGE 1
MARKET - NOT ON FILE
TERRITORY - 73999 NOT ON FILE
TCO/SUSP TOTAL --------------- CURRENT -------- ------------ PAST DUE ---------- --- NOTES --UA-CASH-
CUSTOMER CODE RECEIVABLES DISCOUNT NET/NET-30 DATINGS 1 MONTH 2 MONTHS 3 MTH/OVER
-ABLE
--
so I would want to use something like the switch command and select the string pattern and specify where to move the file to.
more like this:
REPORT - ARB015B AS OF 02/28/2011 RUN 03/05/2008
COMPANY - 3 . ANALYSIS OF ACCOUNTS RECEIVABLE PAGE 1
MARKET - NOT ON FILE
TERRITORY - 73999 NOT ON FILE
TCO/SUSP TOTAL --------------- CURRENT -------- ------------ PAST DUE ---------- --- NOTES --UA-CASH-
CUSTOMER CODE RECEIVABLES DISCOUNT NET/NET-30 DATINGS 1 MONTH 2 MONTHS 3 MTH/OVER
-ABLE
--
so I would want to use something like the switch command and select the string pattern and specify where to move the file to.
ASKER
I got the script to work for me so here are your points - thanks!