I am trying to create a macro that moves a selected file in a finder window to a new pre determined location using AppleScript which works. But how do I get the selection to return to the next file in the finder window?
For example if the finder window contains the following filenames;
Name 1
Name 2
Name 3
Name 4
If my script moves file "Number 2" I would like the selectioin to comeback and select "Number 3". My file move AppleScript is as follows;
on run {input, parameters}
set targetfolder to POSIX file "/Users/jeff/Downloads/Gathered/To Be Converted/Writing" as alias
repeat with thefile in input
try
tell application "Finder" to move ((thefile) as alias) to folder (targetfolder)
end try
end repeat
end run
Is it easier to coerce KM to do this or am I in need of s Shell script?
I tried this AppleScript but I'm not getting the desired results;
tell application "Finder"
set frontWindow to front window
if frontWindow exists then
set currentSelection to selection
if currentSelection is not {} then
set selectedItem to item 1 of currentSelection
set selectedFile to (target of selectedItem) as alias
set currentFolder to container of selectedFile
set fileNames to name of every file of currentFolder
set currentIndex to item 1 of (get selectedFile's name in fileNames)
set nextIndex to currentIndex + 1
if nextIndex is less than or equal to (count of fileNames) then
set nextFileName to item nextIndex of fileNames
set nextFile to file nextFileName of currentFolder
select nextFile
end if
end if
end if
end tell
Hopefully someone can direct me to a solution or hints on this problem.