Expect - get, then move files within FTP site?

Trying to do the following, and it looks like Expect is probably my best bet. Any help greatly appreciated

1) Log onto ftp site
2) Go to folder
3) GET all files matching basename*.txt
4) MOVE those files to a subfolder on the ftp site. I don't need to move it on MY computer, I want to move the files on the site to a subfolder, so that if there are any problems the files are still accessable. This is acceptable by the site owner.

Example:
spawn ftp myftp
expect "username:"
send "hi\r"
expect "password:"
send "mom\r"
expect "ftp>"
send "prompt\r"
expect "ftp>"
send "cd getme\r"
expect "ftp>"
send "mget basename*.txt\r"
expect "ftp>"
(code I need - move all files I just got to folder getme\processed)
send "bye\r"
expect eof

Not sure about this, but try "rename" on the ftp prompt:

rename myfile ./subfolder/myfile

assuming the subfolder exists and you have permissions to it.
Try absolute path if relative balks.

Another way would be to mput them back from your machine to the subfolder on the remote machine, although I suspect you're trying to avoid that.

tyler_durden

Yes, something like that would work... but I still need a way for expect to figure out the list of files, then loop through each and get/rename.