Move folder into folder, based on partial match of name
In applescript, let's say I have a folder with a certain name. In another location, a folder exists, that has a partial match to the certain name of the first folder.
So far, I've hacked together this script, that seems to succeed in finding partial matches between strings:
set sourceFolder to {"RS_W36_21_NEWS", "TV1016_RS_W20_10_GO"}
set destFolder to {"RS_W35_GO", “BLURB_RS_W36_21_NEWS_GO"}
set TID to text item delimiters
set text item delimiters to "\\|"
set grepItems to sourceFolder as text
set text item delimiters to linefeed
set FolderText to destFolder as text
set matches to do shell script "echo " & quoted form of FolderText & " | grep " & quoted form of grepItems
set res to matches as text
display dialog res
This prints "BLURB_RS_W36_21_NEWS_GO", which is to be expected, since the source has a string of "RS_W36_21_NEWS".
My question is, how can I update the script to move the folder into the partially matching folder?
From the dialog, it is clear that there is a match, I just can't figure out the method for actually moving the file into the matching location.