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?
Hello,

Is there a way to test against the file extension of a file name? After uploading file of various types, I would like to move them to subdirectories, based on their file extension. For example, .mpg files would get moved to a Videos subdirectory, .doc files would get moved to Scripts, etc.

Something like:
IF($file=="*.mpg")

Is that possible? Thank you for your help.
Hi Tim,

It can be done this way:
Code: Select all#Connect to FTP server OPENHOST("ftp.myhost.com","myuserhere","mypasswordhere") # Change current local directory to D:\files LOCALCHDIR("D:\files") # Upload everything PUTFILE("*.*") # Get the remote file listing filtering the results to doc files only GETLIST($docfileslist,REMOTE_FILES,"*.doc") FOREACH $file IN $docfileslist # Warning, moving files this way only works   # on some FTP servers. See renamefile help topic RENAMEFILE($file,"docfilesdir/".$file) ENd FOREACH # Get the remote file listing filtering the results to txt files only GETLIST($txtfileslist,REMOTE_FILES,"*.txt") FOREACH $file IN $txtfileslist # Warning, moving files this way only works   # on some FTP servers. See renamefile help topic RENAMEFILE($file,"txtfilesdir/".$file) ENd FOREACH CLOSEHOST()