• 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: Renaming multiple files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Renaming multiple files


  • Subject: Re: Renaming multiple files
  • From: "Mark J. Reed" <email@hidden>
  • Date: Thu, 4 Dec 2008 09:53:36 -0500

On Thu, Dec 4, 2008 at 9:28 AM, Mark J. Reed <email@hidden> wrote:
> ls -1 srcdir | perl -ne 'chomp; rename($_, "destdir/$..xls") or die $! '

Sorry, I just have two small improvements to my own command before I
shut up about Perl and let you get back to your regularly scheduled
AppleScript discussion, already in progress. :)

First, using Fatal.pm makes it easier to get error messages when
something goes awry (and improves their quality over the bare $! I
used above).

Second, I just remembered that the -l option to perl does autochomping
of input as well as auto-newline-appending on output.  So it can be
rewritten as below:

ls -1 srcdir | perl -MFatal=rename -lne 'rename ($_, "destdir/$..xls")'

--
Mark J. Reed <email@hidden>
 _______________________________________________
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: 
 >Renaming multiple files (From: Miguel Moya <email@hidden>)
 >Re: Renaming multiple files (From: Chris Page <email@hidden>)
 >Re: Renaming multiple files (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: Renaming multiple files
  • Next by Date: Problem getting files by file type or extension
  • Previous by thread: Re: Renaming multiple files
  • Next by thread: Re: Renaming multiple files
  • Index(es):
    • Date
    • Thread