Replace in Filenames

Summary: Lets you make changes to the filenames of the selected records using find and replace.
Requires: EagleFiler
Install Location: ~/Library/Scripts/Applications/EagleFiler/
Last Modified: 2011-11-09


EagleFiler will replace the source string with the replacement string in the filename of each selected record. This script deals with Unix filenames, so for a “/” character as shown in EagleFiler enter “:”, and for a “:” character enter “/”.

See also Replace in Filenames (Regex).

Installation Instructions · Download in Compiled Format · Download in Text Format


tell application "EagleFiler"
set theSource to my promptForString("Enter text to find in the filenames:")
if theSource is not "" then exit repeat
end repeat
set the theReplacement to my promptForString("Enter replacement text:")
set theRecords to selected records of browser window 1
tell library document 1
repeat with theRecord in theRecords
set theName to theRecord's filename
set filename of theRecord to my replace(theName, theSource, theReplacement)
end repeat
end tell
end tell

on promptForString(thePrompt)
display dialog thePrompt default answer "" buttons {"Cancel", "OK"} default button 2
return text returned of the result
end promptForString

on replace(theString, theSource, theReplacement)
set AppleScript's text item delimiters to theSource
set theItems to every text item of theString
set AppleScript's text item delimiters to theReplacement
return theItems as Unicode text
end replace