Extract filename from text file and then extract a string from that file

Joined
Mar 8, 2018
Messages
2
Reaction score
0
Hi all, I'm trying to figure out if I can use Automator for this task.

I need to 1) extract text from a text file (FILE1), including a filename for a photoshop tiff file, 2) open the tiff file as text and extract a string, 3) combine the text from step 1 and 2 in a new text file (FILE2), and 4) repeat for all lines in the first text file that meet certain criteria.

My first text file (FILE1) looks like this:

TITLE: 20170513 Ricky Ma SUBBED EDL TEST
FCM: NON-DROP FRAME

001 BL V C 00:00:00:00 01:30:09:10 00:00:00:00 01:30:09:10

002 AX V C 00:00:00:00 00:00:01:13 01:30:09:10 01:30:10:21
* FROM CLIP NAME: 20170513 Ricky Ma 0003.tif

003 BL V C 00:00:00:00 00:00:00:11 01:30:10:21 01:30:11:08

004 AX V C 00:00:00:00 00:00:01:01 01:30:11:08 01:30:12:09
* FROM CLIP NAME: 20170513 Ricky Ma 0004.tif

005 BL V C 00:00:00:00 00:00:00:20 01:30:12:09 01:30:13:05

006 AX V C 00:00:00:00 00:00:00:10 01:30:13:05 01:30:13:13
* FROM CLIP NAME: 20170513 Ricky Ma 0005.tif

007 BL V C 00:00:00:00 00:00:05:11 01:30:13:13 01:30:19:00

008 AX V C 00:00:00:00 00:00:01:16 01:30:19:00 01:30:20:13
* FROM CLIP NAME: 20170513 Ricky Ma 0006.tif

009 BL V C 00:00:00:00 00:00:02:18 01:30:20:13 01:30:23:07

010 AX V C 00:00:00:00 00:00:02:16 01:30:23:07 01:30:25:20
* FROM CLIP NAME: 20170513 Ricky Ma 0007.tif​

For each line with "AX" in positions 6-7, extract columns 54-64 (START_TC), 66-76 (END_TC), and columns 19-end of the next line (TIFF_NAME). In this example, the first line of interest is line 3, starting with 002 AX:

START_TC = 01:30:09:10
END_TC = 01:30:10:21
TIFF_NAME = 20170513 Ricky Ma 0003.tif
For each TIFF_NAME, search for the <photoshop:LayerText> tag and extract its contents (TITLE_TEXT).

Create a new text file (FILE2) like this (and append successive lines):

START_TC , END_TC , TITLE_TEXT
START_TC , END_TC , TITLE_TEXT
And so on for every instance in FILE1.

Is it possible to do this in Automator? Any thoughts on the best approach?

Many thanks in advance!

Joe
 

Cory Cooper

Moderator
Joined
May 19, 2004
Messages
11,098
Reaction score
500
Hello and welcome.

That is way above my experience level with Automator/AppleScript. In addition, I don't believe Automator/AppleScript are capable of opening graphics files as text files, so it probably wouldn't work.

C
 
Joined
Mar 8, 2018
Messages
2
Reaction score
0
Hello and welcome.

That is way above my experience level with Automator/AppleScript. In addition, I don't believe Automator/AppleScript are capable of opening graphics files as text files, so it probably wouldn't work.

C

Thanks Cory! I actually got a friend to write me a python script to do this, so problem solved.
 

Cory Cooper

Moderator
Joined
May 19, 2004
Messages
11,098
Reaction score
500
No worries...glad you found a solution.

I figured it would take a much more robust scripting solution than Automator/AppleScript.

C
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top