When I drag files from one folder to another in the finder in Mavericks, if there are duplicates, the dialog box gives me the option to click “Keep Both,” which adds a number to the end of the duplicate filename while keeping the extension intact.
Is there a simple way to make this happen in an applescript?
I have been searching and have found lots of interesting stuff, but nothing that will duplicate this functionality.
Embarassingly simple, here’s what I have so far!
I have been working on that, and actually have more decision points, also. I stumble through the occasional Applescript project about once every 3 years, so I never quite learned it!
I have files starting with a part number, then a dash, then some codes. If the first 6 digits are not a number 100,000 or higher, then I want to kick the file into the Problems folder to deal with manually.
If it passes that test, then I want to move the file to a backup folder, and if there is a duplicate, I want to append it with a number, just to make it unique.
Here’s where I’m at so far, and I feel like a bumbling idiot!! I am trying to work out a kludge of code from other scripts to make this happen!
Any help would be GREATLY appreciated.
property folderA : "Macintosh HD:Users:fmserver:SCAN:"
property folderB : "2Tb Backup:ScanBackups:"
property folderC : "Macintosh HD:Users:fmserver:SCAN:Problems:"
tell application "Finder"
set thisfolder to folderA as alias
set mylist to (every file in thisfolder) as alias list
set thisfolder to thisfolder as text
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "-"
repeat with eachfile in mylist
set n to name of eachfile
set w1 to text item 1 of n
if w1 < 100000 then
move n to folderC
else
if
else
end if
end if
try
on error
end try
end repeat
set AppleScript's text item delimiters to tid
end tell
If it’s not a number, then it won’t add up to 100000, correct? I think that will be test enough, am i right? Or am I missing something?
Also, the way I have it written now, it considers the first “word” up to the dash. My concern is that if someone enters 7 digits instead of 6, then the mistake will not be fought. What is the syntax to consider only the first 6 characters of the name?