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

Rép: duplicate


  • Subject: Rép: duplicate
  • From: Yvan KOENIG <email@hidden>
  • Date: Tue, 10 Oct 2006 14:55:39 +0200

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

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

  • Prev by Date: Rép: duplicate
  • Next by Date: Re: duplicate
  • Previous by thread: Rép: duplicate
  • Next by thread: Re: Rép: duplicate
  • Index(es):
    • Date
    • Thread