Re: Script to replace lost file extension
Re: Script to replace lost file extension
- Subject: Re: Script to replace lost file extension
- From: Brett Conlon <email@hidden>
- Date: Wed, 25 Apr 2007 09:03:26 +1100
This is a handler from a script I just
recently finished, with the help of this list, that I use for checking
image files in a graphic design job folder. You could repurpose it to whatever
you like:
on
CheckImgsFldr(ThisItem,
aFolder)
tell
me
to
activate
tell
application
"Finder"
try
set
ImgsFldr
to
(first
folder
of
ThisItem
whose
name
contains
"Images")
on
error
beep
tell
me
to
display dialog
"I can't locate your Images Folder. Checking for foreign files connot
continue." buttons
{"OK"} default
button 1 with
icon caution
with title
aFolder
return
end
try
try
set
ImgFiles
to
(document files
of
entire contents
of
ImgsFldr)
on
error
select
ImgsFldr
beep
tell
me
to
display dialog
"There are no files in your Images Folder." buttons
{"OK"} default
button 1 with
icon caution
with title
aFolder
return
end
try
set
FailedNames
to
{}
set
FailedFiles
to
{}
tell
(ASCII character
0) to
set
NullType
to
it
& it
& it
& it
set
TypeList
to
{"EPSF", "TIFF", "EPSP", "JPEG",
"BMP "}
set
KindList
to
{"EPS File", "Adobe Photoshop TIFF file", "Adobe
Photoshop EPS file", "Adobe Photoshop BMP file"}
set
AppleScript's
text item delimiters
to
return
repeat
with
i
in
ImgFiles
set
{name:Fname,
file type:Ftype,
kind:Fkind}
to
info for
i
as
alias
if
Ftype
is not
in
TypeList
and
Fkind
is not
in
KindList
then
if
Ftype
is
NullType
then
set
Ftype
to
"unspecified"
set
end
of
FailedNames
to
Fname
& {"", " [TYPE: " & Ftype
& "]", " [KIND: " & Fkind
& "]"}
set
end
of
FailedFiles
to
i's
contents
end
if
end
repeat
set
FailedCount
to
count
FailedNames
if
FailedCount
is
0 then
set
AppleScript's
text item delimiters
to
{""}
else
set
AppleScript's
text item delimiters
to
return
& return
set
msg
to
{"The following " & FailedCount
& " files ", "The following file "}'s item
(1 + 1 div
FailedCount)
& {"(now selected in the Finder) may not belong in your Images
folder:", FailedNames,
""}
set
AppleScript's
text item delimiters
to
{""}
select
FailedFiles
beep
if
button returned
of
(display dialog
msg
buttons
{"Cancel", "Fix now", "Fix at end"} default
button 1 with
title aFolder)
is
"Fix now" then
FixNow()
end
if
end
tell
end
CheckImgsFldr
Cheers,
Cojcolds
"Stockly, Ed"
<email@hidden>
Sent by: applescript-users-bounces+brett.conlon=email@hidden
25/04/07 04:44 AM
|
To
| <email@hidden>
|
cc
|
|
Subject
| Re: Script to replace lost file extension |
|
>>> There must be a shell script that can determine what a file's
extension was.
I don't think so, but there may be an AppleScript solution.
Ask finder for the file type and creator type. You may get a result that
could tell you what extension to use.
You may need to do some trial and error, and this would only work with
those
files you've mapped a file/creator types to a specific extension, but it
should work if you're not dealing with an unlimited variety of file types.
If you're interested I could post a sample of how it would work.
HTH,
ES
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden