• 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: Philip Aker <email@hidden>
  • Date: Thu, 4 Dec 2008 05:36:57 -0800

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@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: Miguel Moya <email@hidden>
References: 
 >Renaming multiple files (From: Miguel Moya <email@hidden>)

  • Prev by Date: How does one add a sub-topic (or sub-sub-topic, or sub-sub-sub-topic) to an InDesign index?
  • Next by Date: Re: Renaming multiple files
  • Previous by thread: Renaming multiple files
  • Next by thread: Re: Renaming multiple files
  • Index(es):
    • Date
    • Thread