• 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: Rép: duplicate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rép: duplicate


  • Subject: Re: Rép: duplicate
  • From: ishmael <email@hidden>
  • Date: Tue, 10 Oct 2006 15:44:46 +0200

Thanks a lot to everyone for the help!

I was writing something like what you sent (move the file to a
temporary directory, create an unique name), but your code is a lot
better than mine! I didn't know you could retrieve the path of the
system temp with (path to "temp" from user domain), and i wrote down
something a bit baroque...thanks a lot!

Mauro

On 10/10/06, Yvan KOENIG <email@hidden> wrote:

Hello

Here is a script I uses from time to time:

--[SCRIPT]
set sourceFile to choose file
set destFolder to choose folder

tell application "Finder"
 set origName to name of sourceFile
 if not (exists file ((destFolder as text) & origName)) then
 duplicate sourceFile to destFolder
 else
 set tempFolder to (path to "temp" from user domain) as alias
 set tempFile to duplicate sourceFile to tempFolder
 set unique to my buildUniqueName(destFolder, sourceFile)
 set name of tempFile to unique
 move file ("" & tempFolder & unique) to destFolder
 end if
end tell

-- ==========

on buildUniqueName(df, sf)
 local n1, xn, begName, n, n2, newPath
 tell application "Finder"
 set n1 to name of sf
 try
 set xn to "." & (name extension of sf)
 set begName to text 1 thru (-1 - (length of xn)) of n1
 on error
 set {xn, begName} to {"", n1}
 end try
 set n to 1
 repeat
 set n2 to �
 begName & (text -4 thru -1 of ("0000" & n)) & xn
 set newPath to "" & df & n2
 if exists file newPath then
 set n to n + 1
 else
 exit repeat
 end if
 end repeat
 end tell -- to Finder
 return n2
end buildUniqueName
-- ==========
--[/SCRIPT]

�
Yvan KOENIG




_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription:
This email sent to 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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: R é p: duplicate
      • From: Paul Berkowitz <email@hidden>
References: 
 >Re: duplicate (From: Yvan KOENIG <email@hidden>)
 >Rép: duplicate (From: Yvan KOENIG <email@hidden>)
 >Rép: duplicate (From: Yvan KOENIG <email@hidden>)

  • Prev by Date: Re: duplicate
  • Next by Date: Get file path via textfile or directly on volume
  • Previous by thread: Rép: duplicate
  • Next by thread: Re: R é p: duplicate
  • Index(es):
    • Date
    • Thread