Monday, July 16, 2018

#1 2010-12-02 09:17:03 pm

Kemalski
Member
Registered: 2009-02-05
Posts: 57

merging multiple files

I found quite a few script explaining how to merge multiple files within 1 folder.

But I need a script where I can point the (text) files and then merge into new file on the desktop.

The script works fine with 1 text file but gives me the

Can’t make quoted form of POSIX path of {alias "Macintosh HD:Users:Kemal:Desktop:log1.txt", alias "Macintosh HD:Users:Kemal:Desktop:log2.txt"} into type Unicode text.

error with multilpe files. How can I get this script working ?

any help is appreciated!


Applescript:


set filez to choose file with prompt "Choose file(s)" with multiple selections allowed

set loc to path to desktop

do shell script "cat " & quoted form of POSIX path of filez & ">" & quoted form of POSIX path of loc & "tezt.txt"

KML:)

Offline

 

#2 2010-12-03 09:38:08 am

marlon4417
Member
From:: NJ
Registered: 2007-11-28
Posts: 62

Re: merging multiple files

Hello Kemalski,

Try this out:

Applescript:


set folder_ to (choose folder with prompt "Select the folder containing .txt files.")
set output_ to (choose file name with prompt "Choose a name and location for the merged file.")
tell application "Finder" to set files_ to files of folder_ as alias list

try
   set file_ref to open for access output_ with write permission
   repeat with file_ in files_
       set text_ to read file_
       write (text_ & return) to file_ref starting at eof
   end repeat
   try
       close access file_ref
   end try
on error e
   display dialog e
   try
       close access file_ref
   end try
end try

The will ask you for your folder containing the text files and then the final merged file will be in the location you specified.  Hope that helps...

Marlon

Offline

 

#3 2010-12-03 04:56:22 pm

Kemalski
Member
Registered: 2009-02-05
Posts: 57

Re: merging multiple files

Thank you. I altered it to work with files in stead of folder but it works. Now I want more offcourse smile

KML

Offline

 

#4 2010-12-03 05:57:46 pm

marlon4417
Member
From:: NJ
Registered: 2007-11-28
Posts: 62

Re: merging multiple files

Oh you're welcome.  This forum has helped me tremendously, and now it's time to give back!
Marlon

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)