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?
Is it possible execute a Find & Replace in file names. I need to find the "&" character in file names & replce with the word "and".

Fooling around with the stock code but no success.
FTP Script
  1. # Change current remote dir to /files_to_rename
  2. CHDIR("public_html/gallery/albums/2001/Test")
  3. # Get the remote file listing, store it in $list
  4. $result=GETLIST($list,REMOTE_FILES,"*.txt")
  5. # For each file in $list...
  6. FOREACH $item IN $list
  7.    # Rename a file adding a prefix to the
  8.    # current file name
  9.    RENAMEFILE($item,"myprefix-".$item)
FTP Script
  1. $FileName="File && Name & Something.Ext"
  2. $Len=TEXTLENGTH($FileName)
  3. $Pos=1
  4. WHILE($Pos<=$Len)
  5.   IF(TEXTCUT($FileName, $Pos, 1)=="&")
  6.     $FileName=TEXTCUT($FileName, 1, $Pos-1)."and".TEXTCUT($FileName, $Pos+1, $Len-$Pos)
  7.     $Pos=$Pos+2
  8.     $Len=$Len+2
  9.   END IF
  10.   $Pos=$Pos+1
  11. PRINT($FileName)