Move file to certain folder based on a value within the file

Discuss Task Sequences and Scripting related issues.

Move file to certain folder based on a value within the file

Postby Tech Support » Mon Nov 05, 2012 1:19 pm

This is a user email support request:

We need to move XML files when they are received/saved into a directory, say c:\XMLrecieved, then depending on the below criteria the files need to be moved out to different directories:-

If the file contains ‘TransactionType=”PreIssue”’ move to c:\preissue
If the file name is like LBO_ move to c:\lbo
And if the file name is like TTS move to c:\TTS

I can see how to move the files based on file name, but can I move the files based on a value within the file ?
Tech Support
Site Admin
 
Posts: 1276
Joined: Thu May 25, 2006 11:12 am

Postby Tech Support » Mon Nov 05, 2012 1:21 pm

1) If you are using Automize, you can use the Text Search Task (New Task button – Text – Text Search). Create a new task call ‘txtsrch’.

2) If the term TransactionType=”PreIssue” is found, the Text search task exit code is set at –100. Otherwise exit code = 0.

3) Additionally, the files where the term is found is saved into a variable called: txtsrch::Filenames . This variable is specially formatted for use in the filename field of other tasks.

4) So create a new Task Sequence task (Front panel – Task Sequence Button) with following steps:
a) step 1 = Text search task - set condition - if exit code = 0 , exit chain
b) step 2 = Copy files task (move option) - set filename field = $%txtsrch::Filenames%$ ..

5) Schedule the Task sequence to run.
Tech Support
Site Admin
 
Posts: 1276
Joined: Thu May 25, 2006 11:12 am


Return to Task Sequences, Chains and Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

cron