• 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: Miguel Moya <email@hidden>
  • Date: Thu, 04 Dec 2008 14:45:24 +0100

Many thanks Philip for your prompt reply.
I'll try it and let you know.



Best regards,
Miguel






Philip Aker escribió:
On 2008-12-04, at 02:40:54, Miguel Moya wrote:

Hello all,
I need an script that can do the following:

-Count the number of files of folder "A".
-Starts a repeat command using the number of files.
-Takes the first file of this folder, rename it always with the same name (always 1.xls) and move it to folder "B" overwriting the previous file.
-Go to the next file.


All files have secuencial numbers as a name (1.xls, 2.xls, 3.xls)

Can you help me?

Maybe.
It's sometimes a problem because the way the files are listed by scripting utilities is not always the same as what you see in the Finder.
In the script below change the "*cp -f*" in 'do shell script' to "*mv -f*" once you are sure everything works ok.


set *indir* to (choose folder with prompt "*Choose Input Folder*")
set *outdir* to (choose folder with prompt "*Choose Output Folder*")
set *inpath* to POSIX path of *indir*
set *outpath* to POSIX path of *outdir*
tell application "*System Events*"
set *flist* to name of files of *indir* whose name extension is "*xls*"
end tell
repeat with *i* from *1* to count of *flist*
set *infile* to (*inpath* & item *i* of *flist*)
set *outfile* to (*outpath* & (*i* as text) & "*.xls*")
do shell script "*cp -f *" & quoted form of *infile* & space & quoted form of *outfile*
end repeat




Philip Aker
echo email@hidden <mailto:email@hidden>@nl | tr a-z@. p-za-o.@

Democracy: Two wolves and a sheep voting on lunch.

_______________________________________________
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
  • Follow-Ups:
    • Re: Renaming multiple files
      • From: Philip Aker <email@hidden>
References: 
 >Renaming multiple files (From: Miguel Moya <email@hidden>)
 >Re: Renaming multiple files (From: Philip Aker <email@hidden>)

  • Prev by Date: Re: Renaming multiple files
  • Next by Date: Re: Renaming multiple files
  • Previous by thread: Re: Renaming multiple files
  • Next by thread: Re: Renaming multiple files
  • Index(es):
    • Date
    • Thread