Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Remove file script not working

dbWizard wrote:

If the automated process gets disconnected, is there a way, in the script, to force the it to reconnect and continue?

No, WinSCP cannot reconnect in the middle of the rm command.

Is there a way, in the script to ignore the error or not generate an error if the file in the remove command is not found on the server?

No. You can suppress all errors only using option batch off.

You have reached a point, when using WinSCP .NET assembly from a PowerShell script would be a way more effective and flexible.

See the guide for converting a script to PowerShell.
dbWizard

Remove file script not working

Martin, I've attached two files

I thought I had this working for a small number of files, but I will frequently have over 1000 files to delete, so I tried it again with a list of 1836 file names and it did not appear to remove any.

If the automated process gets disconnected, is there a way, in the script, to force the it to reconnect and continue?

Is there a way, in the script to ignore the error or not generate an error if the file in the remove command is not found on the server?

The first (radD6324.txt) contains the script for performing the remove action.

The second (rad006E3.txt) contains the output file from the delete process.

I attempted to sanitize these two files but I've made the attachments private just in case.

Thanks for your assistance.
martin

Re: Delete multiple files from FTP Server after downloading and processing.

Show us a full log file. The snippet, you have posted, does not show deleting of the files.
dbWizard

Delete multiple files from FTP Server after downloading and processing.

Well, the files are not being removed from the FTP server, and I assumed that this line:

550 The filename, directory name, or volume label syntax is incorrect

was probably responsible for the files not being removed. If that is not the cause for the files not being deleted, do you have any idea why they might not be deleting?

Dale
martin

Re: Remove file script not working

There's no indication that "it is not finding these files" in the log.

Do you have an actual problem or are you just trying to interpret the log file?
dbWizard

Remove file script not working

Running a script to delete files which have already been downloaded, but this is not a synch/delete issue. I'm running the following script:
open ftpes://UserID:Password@URL// -Explicit

# Change the remote directory
cd /XML/Test/Out
# add the rm for removing files
rm 0000013261_MyCORP_4167343_20160608-190425-989.xml 0000013261_MyCORP_4167763_20160608-200657-159.xml
0000013261_MyCORP_4167764_20160608-200705-959.xml
0000013261_MyCORP_4167765_20160608-200705-993.xml 0000013261_MYCORP_4167766_20160608-200657-186.xml
Exit
These files are all present ON the FTP server, in the folder indicated. The script is connecting to the server and generating the following output:

. 2016-06-13 17:03:56.324 Using FTP protocol.

. 2016-06-13 17:03:56.324 Doing startup conversation with host.
> 2016-06-13 17:03:56.325 PWD
< 2016-06-13 17:03:56.402 257 "/" is current directory.
. 2016-06-13 17:03:56.402 Changing directory to "//".
> 2016-06-13 17:03:56.402 CWD //
< 2016-06-13 17:03:56.452 250 CWD command successful.
. 2016-06-13 17:03:56.452 Getting current directory name.
> 2016-06-13 17:03:56.452 PWD
< 2016-06-13 17:03:56.504 257 "/" is current directory.
. 2016-06-13 17:03:56.504 Startup conversation with host finished.
< 2016-06-13 17:03:56.504 Script: Active session: [1] UserID@URL
> 2016-06-13 17:03:56.504 Script: cd /XML/Test/Out
. 2016-06-13 17:03:56.504 Cached directory change via "/XML/Test/Out" to "/XML/Test/Out".
. 2016-06-13 17:03:56.504 Getting current directory name.
< 2016-06-13 17:03:56.504 Script: /XML/Test/Out
> 2016-06-13 17:03:56.504 Script: rm 0000013261_MyCORP_4167343_20160608-190425-989.xml 0000013261_MyCORP_4167763_20160608-200657-159.xml 0000013261_MyCORP_4167764_20160608-200705-959.xml 0000013261_MyCORP_4167765_20160608-200705-993.xml 0000013261_MyCORP_4167766_20160608-200657-186.xml
. 2016-06-13 17:03:56.504 Listing file "0000013261_MyCORP_4167343_20160608-190425-989.xml".
. 2016-06-13 17:03:56.504 Retrieving file information...
> 2016-06-13 17:03:56.504 PWD
< 2016-06-13 17:03:56.555 257 "/" is current directory.
> 2016-06-13 17:03:56.555 CWD /XML/Test/Out/0000013261_MyCORP_4167343_20160608-190425-989.xml
< 2016-06-13 17:03:56.606 550 The filename, directory name, or volume label syntax is incorrect.
> 2016-06-13 17:03:56.606 TYPE I
< 2016-06-13 17:03:56.656 200 Type set to I.
> 2016-06-13 17:03:56.656 SIZE /XML/Test/Out/0000013261_MyCORP_4167343_20160608-190425-989.xml
< 2016-06-13 17:03:56.707 213 2911
> 2016-06-13 17:03:56.707 MDTM /XML/Test/Out/0000013261_MyCORP_4167343_20160608-190425-989.xml
< 2016-06-13 17:03:56.759 213 20160608190600
This is only one of the five files in the current script, but all five are showing this same set of messates.

Why is it not finding these files in the Remote FTP site? I have confirmed manually that these files exist.