Re: Checking if a folder exists and dealing with it
Re: Checking if a folder exists and dealing with it
- Subject: Re: Checking if a folder exists and dealing with it
- From: César Escolar <email@hidden>
- Date: Thu, 5 Dec 2002 10:55:27 +0100
Under mac os X you can also use "do shell script" an shell commands,
in certain cases (all most) is fastest than the finder.
You can use in this form (with many do shell scripts managed by
applescript) or all commands in one shell script and only a "do shell
script" call. (whit the repeat and so...) (i think is faster)
set directorio to "/hola/" -- start folder
set directorios to every paragraph of (do shell script "ls -1F " &
directorio & " | grep /") -- list folder items in start folder
repeat with i from 1 to (length of directorios)
try
do shell script (("ls " & directorio & "'" & (item i of directorios)
& "' | grep Templates") as string) -- list with grep for find mached
on error
do shell script (("mkdir " & directorio & "'" & (item i of
directorios) & "Templates'") as string) -- on error make dir
end try
end repeat
El miircoles, 4 dici, 2002, a las 18:09 Europe/Madrid, Mr Tea escribis:
>
This from Chad Chelius - dated 04-12-02 01.17 pm:
>
>
> How can I put error trapping into my script so that if
>
> this folder does exist, it will simply skip over it and go to the
>
> next one.
>
>
>
> make new folder in every item of ShortFoundTemplateMatches with
>
> properties
>
> {name:"Templates"}
>
>
>
A repeat loop is probably needed here. Replace the above section of
>
your
>
script with:
>
>
>
set theFolders to every folder of ShortFoundTemplateMatches
>
repeat with aFolder in theFolders
>
try
>
make new folder at aFolder with properties {name:"Templates"}
>
end try
>
end repeat
>
>
>
... this assumes that you are working in a Finder tell block, and that
>
your
>
variable is a list of aliases or references to Finder items. For more
>
robust
>
error checking that will deal with cases when the error is not caused
>
by the
>
existence of an item with the same name, you could do this:
>
>
>
set theFolders to every folder of ShortFoundTemplateMatches
>
repeat with aFolder in theFolders
>
try
>
make new folder at aFolder with properties {name:"Templates"}
>
on error errmsg number errnum
>
if errnum is not -48 then display dialog errmsg
>
end try
>
end repeat
>
>
>
As before, that needs to be inside a Finder tell block.
>
>
>
HTH
>
>
>
Mr Tea
>
_______________________________________________
>
applescript-users mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.