Enrico Franchi Homepage

Questo sito è obsoleto. La nuova versione di questa pagina è disponibile presso akropolix

This site is old. The new version of this page is available on akropolix

Rename

This simple apple script mimics the way windows rename works. I wasn't aware of this win features, and before I did solve this kind of problems with pure shell works.
This is a pure AppleScript solution.

Rename.applescript (download)
(* 
 * Enrico Franchi ©2005
 * This is Public Domain
 *)

tell application "Finder"
	set mySel to selection
	display dialog ¬
		"Rename file with:" default answer ¬
		"" buttons {"OK", "Cancel"} ¬
		default button "OK"
	set basename to text returned of result
	if basename is equal to "" then
		return
	end if
	set j to 0
	repeat with i in mySel
		set ext to name extension of i
		if ext is not equal to "" then
			set ext to "." & ext
		end if
		if j is greater than 0 then
			set defname to (basename & j as text) & ext
		else
			set defname to basename & ext
		end if
		set j to j + 1
		
		set name of i to defname
	end repeat
end tell

back

xhtml 1.1 CSS 2.1 RSS 2.0
Made with a Mac Made with BBEdit Made with Brain

All documentation is under FDL and all source code is under BSD, unless differently stated.

24-mar-06