I have an apple script which moves all files within a folder into a new folder according to the first 6 characters of the filenames. If the folder already exists, the files get moved into that existing folder instead. If the file already exists in the new/existing folder, the file to be moved into the folder gets a "copy" extension to the filename – which is not in the script, it's a system function ;-)
My question: **Is it possible to move all existing files into a subfolder (named "_alt" for example), before the other files get the "copy"-extension? **
This is my existing script:
set mgFilesFolder to (choose folder with prompt "Choose folder…")
(* get the files of the mgFilesFolder folder *)
tell application "Finder" to set fileList to files of mgFilesFolder
(* iterate over every file *)
repeat with i from 1 to number of items in fileList
set this_item to item i of fileList
set this_file_Name to name of this_item as string
set thisFileCode to characters 1 thru 6 of this_file_Name as text
log thisFileCode
tell application "Finder"
try
set nf to make new folder at mgFilesFolder with properties {name:thisFileCode}
end try
end tell
end repeat
set sourceFolder to mgFilesFolder
set destinationFolder to mgFilesFolder
tell application "Finder"
set the_files to (get files of mgFilesFolder)
repeat with this_file in the_files