Re: .chk files
Re: .chk files
- Subject: Re: .chk files
- From: Paul Scott <email@hidden>
- Date: Fri, 25 Jan 2008 10:09:46 -0800
On Jan 24, 2008, at 8:12 PM, Jordan Hadley wrote:
While I'm at it, I'll ask another question... I'm realizing some of
these files might not be jpegs, and instead could be gifs or tiffs,
or maybe something else entirely.
I read about a Windows data recovery application that looks at the
header to determine what kind of file it is, and then changes the
extension to match... Anybody know of a way to do that on a Mac?
I had some time on my hands, so I reworked my script a bit to use
ImageMagick to determine the picture type. Assuming you've installed
ImageMagick according to the MacOSX instructions ( http://www.imagemagick.org/script/binary-releases.php#macosx
) then this script will modify the file extension of any image files
that ImageMagick recognizes to the type name it returns. I've elected
to convert the extension to lower case and change jpeg to jpg, pict to
pct, and accept the remaining types. Feel free to tweak it anyway you
want. The script won't touch anything that it doesn't recognize or
already has the correct extension.
-- begin script
on run
choose file with prompt "Choose files to process:" default
location (path to desktop) with multiple selections allowed
set ListOfFiles to result as list
Process(ListOfFiles)
end run
on open parms
Process(parms)
end open
on Process(parms)
set numChanged to 0
set numIgnored to 0
repeat with f in parms
set path1 to POSIX path of f
set bash to ""
set bash to bash & "/bin/bash -c \""
set bash to bash & "MAGICK_HOME=/usr/local "
set bash to bash & "/usr/local/bin/identify -quiet -format %m "
set bash to bash & quoted form of path1
set bash to bash & " 2>/dev/null\" "
set bash to bash & "| tr \"[:upper:]\" \"[:lower:]\""
set changed to 0
try
set newext to (do shell script bash)
if length of newext is greater than 0 then
if newext is equal to "jpeg" then
set newext to "jpg"
else if newext is equal to "pict" then
set newext to "pct"
end if
set newext to (do shell script "/bin/bash -c 'echo
${1#\\.}' -- " & quoted form of newext)
set fn to (do shell script "/bin/bash -c 'echo ${1%\
\.*}' -- " & quoted form of path1)
set path2 to fn & "." & newext
set found to "0" is equal to (do shell script "test -
e " & quoted form of path2 & ";echo $?")
if not found then
do shell script "mv -n " & quoted form of path1 &
" " & quoted form of path2 & " > /dev/null"
set changed to 1
end if
end if
end try
if changed is greater than 0 then
set numChanged to numChanged + 1
else
set numIgnored to numIgnored + 1
end if
end repeat
display dialog "Changed " & numChanged & ", Ignored " & numIgnored
end Process
-- end script
Paul
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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