While I love, er, hate to start a religious war, there’s nothing wrong with using POSIX paths as long as you know what you’re doing. I use them almost exclusively at this point, but similarly, I don’t use the Finder for much beyond grabbing the selected files.
______________________________________________________________________
Hey Jon,
Right. You don't use them in the Finder. :)
I don't turn my nose up at Posix Paths, and since FastScripts and Keyboard Maestro will easily run shell scripts I continue to learn more about using Bash and Unix Executables.
For that matter the Terminal has run 24/7 on my system for about 7 years now — I use it several times a day.
#! /usr/bin/env bash
# Task: Change file extensions from 'old' to 'new'.
# dMod: 2015/06/24 23:14
old=dat;
new=csv;
read -r -d '' aplScpt <<'EOF'
try
tell application "Finder" to set targetDir to insertion location as alias
return POSIX path of targetDir
on error
return "false"
end try
EOF
DIR=$(osascript -e "$aplScpt");
if [ ! "$DIR" = "false" ]; then
cd "$DIR";
for file in *."$old"
do
mv "$file" "${file%.$old}.$new";
done
fi
It's not as simple as this:
-------------------------------------------------------------------------------------------
set ext to "dat"
set extNew to "csv"
tell application "Finder"
set name extension of (files of (get insertion location) whose name extension is ext) to extNew
end tell
-------------------------------------------------------------------------------------------
But it won't choke on a really large number of files either.
I like having a variety of tools at my disposal.
--