• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: open different files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: open different files


  • Subject: Re: open different files
  • From: kai <email@hidden>
  • Date: Thu, 7 Jul 2005 13:35:06 +0100


On Thursday, July 7, 2005, at 11:30 am, Jürgen Keser wrote:

I've got an problem with applescript but I think that there is
an easy solution. I've got an folder that contains many
files. I want to open all the files (one after the other)
with an special program and save the files with the programm in
another folder.

Is there an easy way to do this with applescript?

Probably Jürgen, depending on the "special program" involved. In the following example, I've asked Tex-Edit Plus to stand in for it.


BTW, I would have used TextEdit for this demo, but its syntax can be a trifle quirky. It also has (or had, if a fix has surfaced recently) a particularly nasty bug that could convert a folder to a file - with the consequent loss of any files contained therein.

Bear in mind that each app can require different type classes for similar functions - and may behave slightly differently in response to commands that appear to be exactly the same. Check out the particular app's AS dictionary for clarification on this (and don't necessarily believe everything you read). ;-)

(I also assume that the app in question will modify the opened files in some way, otherwise they could simply be duplicated to the target folder.)

Anyway, I hope this gives you some ideas:

----------

set sourceFolder to (choose folder with prompt ¬
	"Choose a source folder:") as Unicode text

set targetFolder to (choose folder with prompt ¬
	"Choose a target folder:") as Unicode text

tell application "Finder" to tell folder sourceFolder's files

	-- the following 'if/then' statement, or a 'try/on error'
	-- block, is needed here to work around a bug...

	if (count) is 1 then
		set filesToProcess to it as alias as list
	else
		set filesToProcess to it as alias list
	end if

end tell

tell application "Tex-Edit Plus" to repeat with currentFile in filesToProcess

open currentFile

tell document 1

(* perhaps do something here with the current document? *)

-- create a path for the new file:
set targetFile to targetFolder & name

-- this could overwrite files that already exist - so maybe check first?...
save in targetFile
(* you may also be able to specify "...saving as [type class]" *)

close
(* some apps may require something like "...with saving no" *)

end tell

end repeat


----------

---
kai

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >open different files (From: Jürgen Keser <email@hidden>)

  • Prev by Date: open different files
  • Next by Date: Re: open different files
  • Previous by thread: open different files
  • Next by thread: Re: open different files
  • Index(es):
    • Date
    • Thread