• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Finder "duplicate" requirements
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finder "duplicate" requirements


  • Subject: Re: Finder "duplicate" requirements
  • From: Christopher Stone <email@hidden>
  • Date: Mon, 29 Jun 2015 07:49:34 -0500

On Jun 28, 2015, at 12:15, Jon Pugh <email@hidden> wrote:
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.

--
Take Care,
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Finder "duplicate" requirements (From: Jean-Christophe Helary <email@hidden>)
 >Re: Finder "duplicate" requirements (From: Jean-Christophe Helary <email@hidden>)
 >Re: Finder "duplicate" requirements (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: sdef etiquette
  • Next by Date: Re: Finder "duplicate" requirements
  • Previous by thread: Re: Finder "duplicate" requirements
  • Next by thread: sdef etiquette
  • Index(es):
    • Date
    • Thread