• 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: Need to rename files/folders - zsh shell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need to rename files/folders - zsh shell


  • Subject: Re: Need to rename files/folders - zsh shell
  • From: Graff <email@hidden>
  • Date: Thu, 10 Jun 2004 18:17:49 -0400

On Jun 10, 2004, at 3:49 PM, Christopher Nebel wrote:

On Jun 10, 2004, at 10:07 AM, Gnarlodious wrote:

zsh:
autoload -U zmv
chars='[][?=+<>;",*-]'
zmv '(**/)(*)' '$1${2//$~chars/%}'

Anyone know how to plug this into Applescript?

Try this:

set s to "autoload -U zmv ; chars='[][?=+<>;",*-]' ; zmv '(**/)(*)' '$1${2//$~chars/%}'"
do shell script "echo " & quoted form of s & " | zsh -s"

Incidentally, you may need to worry about creating collisions -- for instance, "this" and "this?" will wind up having the same name. I expect the zsh script above will simply replace one with the other.

Yeah, I dealt with that in my pure AppleScript example. It will try adding numbers to the end of the file name just before the extension. It will increment until it has tried up to 999 and then it gives up on cleaning that name. If you have more than a thousand files with the same name then you have some serious problems!

- Ken
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: Need to rename files/folders - zsh shell (From: Gnarlodious <email@hidden>)
 >Re: Need to rename files/folders - zsh shell (From: Christopher Nebel <email@hidden>)

  • Prev by Date: Coercion problem
  • Next by Date: Re: run script on remote machine stops working
  • Previous by thread: Re: Need to rename files/folders - zsh shell
  • Next by thread: How to hide toolbar
  • Index(es):
    • Date
    • Thread