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

Hopefully you can see what i am trying to achieve here.

$item is a file name such as "test.txt" or "test file.txt"
i am attempting to delete this file using CMD as follows:

This Works (in CMD):
del test.txt

This Does Not Work (in CMD):
del test file.txt

...Because you have to enclose the file name in "" if it contains spaces, thus:

This Works (in CMD):
del "test file.txt"

Now to ScriptFTP...

I have tried all ways including using ' instead of/combined with " as mentioned at:

http://www.scriptftp.com/reference.php?go=topic260

and various posts in the forum.

The ScriptFTP code is as follows and:

Works:
IF $item = "test.txt"

Does Not Work:
IF $item = "test file.txt"

FTP Script
  1. $CommandLine="del ".$item
  2. EXEC($CommandLine)

Any suggestions greatly appreciated.
FTP Script
  1. $item = '"test file.txt"'
  2. $CommandLine="del ".$item
  3. EXEC($CommandLine)
or
FTP Script
  1. $item = "test file.txt"
  2. $CommandLine='del "'.$item.'"'
  3. EXEC($CommandLine)
as you wish. The second option I like - never forget to use quotes when the list of many files and dynamically generated...
Thanks Wandrey
Its been a while....

I can not get the following to work.
[ScriptFTP]$CommandLine='del /f /q D:\Slides\"'.$item'"'
EXEC($CommandLine)[/ScriptFTP]

The $item is coming from a dynamically generated list of remote files
SOLVED

The correct code should be:

[ScriptFTP]$CommandLine='del /f /q "D:\Slides\'.$item.'"'
EXEC($CommandLine)[/ScriptFTP]

There was a . missing after $item