Dear All,
I’m new here and I hope you can help me!
I got my MacMini for just 3 Weeks and there is a big Problem that i had.
I have a directory with a lot of tiff-images and i want to compress them.
Every single image, because every image is about 2 mb big.
Has anybody also this problem? Does somebody wrote an applescript to do this job automaticly.
I hope you can help me!
Regards,
master07
Hi master07,
assuming you’re talking about OS X you can use this script.
It compresses all files in the chosen folder one by one and deletes the original files
set theFolder to choose folder
zipFiles(theFolder)
on zipFiles(theFolder)
tell application "Finder" to set fileList to files of theFolder
repeat with f in fileList
set {name:Nm, name extension:Ex} to info for (f as alias)
if Ex is missing value then set Ex to ""
if Ex is not "" then set Nm to text 1 thru ((count Nm) - (count Ex) - 1) of Nm
set sourceFile to quoted form of POSIX path of (f as alias)
set zipFile to quoted form of (POSIX path of (theFolder as Unicode text) & Nm & ".zip")
do shell script "/usr/bin/zip -jqmo9 " & zipFile & space & sourceFile
end repeat
end zipFiles
(*
Notes for used zip parameters:
-j junk (don't record) directory names
-q quiet operation
-m move into zipfile (delete files)
-o make zipfile as old as latest entry
-9 compress better
*)
StefanK,
I would love to see this rewritten for a group of folders. I’m working on it myself but having a bit of trouble. I will post it when/if I can get it working.
Oh, I really appreciate that you commented out the Notes for the Zip parameters. Can you post a longer list of all Zip parameters? Anyone?
The following script is a man page “grabber” originally proposed by Nigel Garvey and slightly modified by me. It asks for the man page you want, gets it, converts it to a pdf, displays it in Preview, and stores the PDF for later reference in your Documents folder. Each time it is run, it checks first to see whether you already have it stored and if so gets that, but otherwise gets it anew.
to grabManPg()
set theCommand to ""
repeat while theCommand is ""
activate
display dialog "View man page for this command:" default answer theCommand
set theCommand to text returned of result
end repeat
try
-- the following path is arbitrary - change to suit yourself
set manFolderPath to (path to documents folder as Unicode text) & "Unix 'man' Pages (PDFs):"
set manFile to manFolderPath & theCommand & "-ManPage.pdf"
-- Rather than getting it and converting it, use the copy on file
-- if it exists.
tell application "Finder"
if exists manFile then
open manFile
return true -- drops us out of the handler
end if
end tell
-- Otherwise go to the system and get it. If the directory exists
-- the -p option with mkdir prevents another from being created.
do shell script ("mkdir -p " & quoted form of POSIX path of manFolderPath)
set manFilePath to quoted form of POSIX path of manFile
-- Convert the PostScript file to a PDF file and feed it to "Preview.app"
do shell script "/usr/bin/man -t " & quoted form of theCommand & " | /usr/bin/pstopdf -i -o " & manFilePath & "; open -a /Applications/Preview.app " & manFilePath
on error errorMsg number errorNum
-- usually means it doesn't exist as you've entered it.
display alert "Error " & errorNum message errorMsg buttons "Cancel" default button 1
return false
end try
end grabManPg
grabManPg()
if result is false then return
activate application "Preview"
-- I like to blow it up a bit and then tap the Grow button to resize it
tell application "System Events" to tell process "Preview"
keystroke "++" using command down -- grow it twice
click button 2 of window 1 -- expand the window
click button 1 of tool bar 1 of window 1 -- close the drawer
end tell