Tagin AppleScript sisältävät artikkelit

Siirrä valitut tiedostot uuteen uudelleennimettävään kansioon

Joskus esimerkiksi Lataukset-kansion järjesteleminen saattaa olla tuskaa, sillä kansioon on saattanut kertyä paljon tiedostoja selailun jäljiltä. Tiedostoja on paljon ja ne ovat erityyppisiä (pdf, doc, jpg, dmg, jne.)  Seuraavalla AppleScriptin pätkällä tiedostoja on helppo järjestellä kansioihin. Skripti siirtää valitut tiedostot uuteen kansioon, joka on heti valmis uudelleennimettäväksi. Tämä skripti kannattaa lisätä OS X:n pikanäppäimiin, jolloin sen käyttö helpottuu huomattavasti. Ohje pikanäppäimien muuttamiseen (käsitelty sivuston artikkeleissa aiemmin) löytyy täältä.

(*
Move items into new folder
Author: Barry Els
Version: 1.1
*)

tell application "Finder"
try

set theSelection to selection

set currentPath to ((the first item of the theSelection) as alias)
set parentPath to currentPath

if (currentPath as string) ends with ":" then -- it is a folder
set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}
set the parentPath to (text items 1 thru -3 of (currentPath as string)) as string
set AppleScript's text item delimiters to od
else -- it is a file
set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}
set the parentPath to (text items 1 thru -2 of (currentPath as string)) as string
set AppleScript's text item delimiters to od
end if

try

set newFolder to (my createFolder(parentPath))
move theSelection to newFolder

delay 0.1
set selection to newFolder
tell application "System Events"
keystroke return
quit
end tell

end try

on error
(*
no folder or file is selected, warn the user
*)

display dialog ("Please select one or several items to group" & (theSelection as string))

end try

end tell

on createFolder(selectedPath)
tell application "Finder"
set createdFolder to make new folder at selectedPath
end tell

return createdFolder
end createFolder

, , , ,

Ei kommentteja

Täydennä Osoitekirjan tietoja Enirosta

Itse pidän melko täydellistä osoitekirjaa koneella ja puhelimessa. Yhteystietojen täydentäminen ja tarkistaminen Eniron palvelusta helpottuu parilla AppleScriptillä. Lue loput artikkelista »

, ,

Ei kommentteja