Re: Need to process all files in folder with Applescript and Excel
Re: Need to process all files in folder with Applescript and Excel
- Subject: Re: Need to process all files in folder with Applescript and Excel
- From: Yvan KOENIG <email@hidden>
- Date: Thu, 21 Sep 2006 19:14:48 +0200
Hello
I am unable to test as I never install Microsoft products on my
machine but you may try this script:
--[Script CSV2HTML]
(*
Yvan KOENIG
21 septembre 2006
*)
property english : true
property msg99 : "" -- globale
if english is true then
set _ to choose folder with prompt "Choose the folder storing files
to 'repair'"
else
set _ to choose folder with prompt "Choisir le dossier contenant les
fichiers à corriger"
end if
tell application "Finder" to set laListe to every file in folder _
open (laListe)
-- ================
on open (listeFichiers)
if msg99 = "" then my prepareMessages()
tell application "Finder"
repeat with leFichier in listeFichiers
set laClasse to (class of leFichier)
if (laClasse is not folder) and (laClasse is not application file)
then my TraiteLeFichier(leFichier)
end repeat
end tell -- to Finder
end open
-- ================
on TraiteLeFichier(the_file)
try
set tf to the_file as text
if tf ends with ".csv" then set tf to text 1 thru -5 of tf
(* removes the .csv extension *)
tell application "Microsoft Excel"
activate
open the_file
save active workbook in tf & "_new.html" as HTML
close active workbook without saving
end tell
on error MsgErr number NroErr
if NroErr is not -128 then
beep 2
tell application (path to frontmost application as string) to ¬
display dialog "" & NroErr & " : " & MsgErr with icon 0 ¬
buttons {msg99} giving up after 20
end if
return
end try
end TraiteLeFichier
-- ================
on prepareMessages()
if english is true then
set msg99 to " Oops "
else
set msg99 to " Vu "
end if
end prepareMessages
--[/SCRIPT]
You may use it from the Script Editor, it will ask you to choose the
folder containing your files.
You may save it as an application and run it. It will also ask you to
choose.
Last not least, when saved as an application, you may drag and drop
the folder's icon on the script's icon and it will do its duty.
CAUTION
As it is written, the script removes the ".csv" extension from the
file path before adding "_new.html".
Yvan KOENIG _______________________________________________
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