ftp automation

ScriptFTP

The professional tool to automate FTP, SFTP, FTPS and schedule FTP batch jobs

The forum is now read only. Please, go to the the main ScriptFTP website if you need help.
Need help writing a script? Have any question about ScriptFTP?
Hi there. I stumbled upon ScriptFTP today and it appears to have the ability to do everything I need except for one important part. Can ScriptFTP just move a file from 1 location to another?

I have a pair of clients that I connect to where I will download a new file from a parent directory, and then move that file into an 'archive' subdirectory. I use Filezilla to do this currently, and I just drag the file into the subdirectory. I've seen that there is a download_and_delete option, which could be followed by an upload into the subdirectory to accomplish this task - but the problem is that I'm not actually able to delete files from this FTP, only move them.

So, can I move the file without having to do any deleting or renaming using ScriptFTP?

If so, I'll be buying a license first thing Monday! Thanks in advance! :)
Hello Krisl,

Thanks for posting this question. Many users ask by email how to move files in the FTP site and having this information in the forum will be very useful.

To move a remote file you need to use the RENAMEFILE command, for example:
FTP Script
  1. OPENHOST("ftp.myserver.com","carl","123456")
  2. RENAMEFILE("a.txt","destination_folder/a.txt")
You can find more information in this help topic:

http://www.scriptftp.com/reference.php?go=topic133
Hi There,

How do I archive / move the file to another directory instead of delete on the local computer?

This is the code I have so far after uploading to the ftp server:
FTP Script
  1. FOREACH $item IN $list
  2.     # Upload the file
  3.     $result=PUTFILE($item)
  4.     # If the file has been succesfully uploaded
  5.     # archive the local copy of the file
  6.     IF($result=="OK")
  7.     EXEC('move "'.$item.'" "G:\Archive"')
  8.     END IF
Does this look correct?

Also I want to change G:\Archive into a variable. Example: $ArchivePath
When I create a variable for this it doesn't seem to work.

Example:
FTP Script
  1. $ArchivePath="G:\Archive"
  2. FOREACH $item IN $list
  3.     # Upload the file
  4.     $result=PUTFILE($item)
  5.     # If the file has been succesfully uploaded
  6.     # archive the local copy of the file
  7.     IF($result=="OK")
  8.     EXEC('move "'.$item.'" "$ArchivePath"')
  9.     END IF
The line where you use EXEC is wrong. Try this:
FTP Script
  1. EXEC('move "'.$item.'" "'.$ArchivePath.'"')
Combining quotes and double quotes is sometimes very confusing ;)

Edited: Fixed the script. I also made a mistake with the quotes! thanks cmben
The line where you use EXEC is wrong. Try this:

EXEC('move "'.$item.' '.$ArchivePath.'"')

Combining quotes and double quotes is sometimes very confusing ;)
Sorry the above didn't work for me. Still couldn't find proper path.
I think you might be missing a quote as well ;)

I changed it to the following which seems to work for me:
FTP Script
  1. EXEC('move "'.$item.'" "'.$ArchivePath.'"')
Thanks for your help!