|Nov 21, 2008, 03:56 PM||#1|
Applescript to copy past from multiple txt files
I would like to create a script file that will copy data from only certain sections of txt files and paste the data in a specific way into a new .txt file.
the set up for the data I would like to copy from each text file is
the file name
a string that is the first 8 characters of the 5th line of the file
a string that is the first 8 characters from the 9th line
a string that is the first 8 characters from the 13th line
a string that is the first 8 characters from the 17th line
I need this information to be pasted into the new document as shown below
_first line of txt file_
(filename from 1st file) (tab) (data from 5th line) (tab) (data from 9th line) (tab) (data from 13th line) (tab) (data from 17th line)
_second line of txt file_
((filename from 2st file) (tab) (data from 5th line) (tab) (data from 9th line) (tab) (data from 13th line) (tab) (data from 17th line)
_third line of txt file_
((filename from 3st file) (tab) (data from 5th line) (tab) (data from 9th line) (tab) (data from 13th line) (tab) (data from 17th line)
etc until all files in the folder have been run through.
I am sure there is a really easy way to do this, I am just having trouble finding all the calls for this. It may be easier to do it in a shell also.
Can anyone help me?
|Nov 21, 2008, 04:45 PM||#2|
I can try to get something together when i get a chance but i can't promise anything.
Vista: It's the blond version of OS's; pretty and fun, just... not functional for everything
|Nov 21, 2008, 06:44 PM||#3|
*The title of this file is 0000.txt
the contents of the file is: *
(title "Volume fraction (solids) ")
(labels "Position" "Volume fraction (solids) ")
** so for this txt file the line in the document I am looking for would be
0000 0.145203 0.146001 0.147857 0.149679
|Nov 21, 2008, 09:27 PM||#4|
You probably don't want to copy and paste. Better to open the file and then set variables to the text you want:
set var1 to characters 1 thru 8 of paragraph 5 of document 1
Then build your output by concatenating your strings.
var1 & tab & etc.
Different editors might work better. For example, TextEdit will probably make "characters 1 through 8" into a list, which will then have to be reconverted into a string. You won't see it but it might slow down your script.
If you use Tex-Edit Plus, you can say:
set var1 to text 1 thru 8 of paragraph 5 of document 1
which should go faster, especially if this is in a loop.
What looks large from a distance, close up ain't never that big.
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|Help in applescript; multiple data from 2 txt files to create image file||LERsince1991||Mac Programming||9||Nov 17, 2011 06:52 AM|
|Applescript to copy highlighted folder name to iCal ToDo List||inaka||Mac Programming||0||Sep 15, 2011 07:38 PM|
|method to extract data from multiple csv files||shaunb83||Mac Programming||1||Jun 8, 2010 08:14 PM|
|Help: cannot copy/paste from Safari to/from X11||haquae||MacBook Pro||0||Oct 8, 2009 11:16 AM|
|How to copy clips from one imovie file to another||masterjedi73||Mac Basics and Help||4||Nov 8, 2005 04:35 AM|
All times are GMT -5. The time now is 01:29 AM.