Topic "Remove file script not working"

Author Message
dbWizard
[View user's profile]

Joined: 2016-05-27
Posts: 7
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:
Code:

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:

Code:
. 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.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
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
[View user's profile]

Joined: 2016-05-27
Posts: 7
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
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
Show us a full log file. The snippet, you have posted, does not show deleting of the files.
dbWizard
[View user's profile]

Joined: 2016-05-27
Posts: 7
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.
rad006E3.txt (204.55 KB) Private file

Description: output file

radD6324.txt (96.06 KB) Private file

Description: remove script

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
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.

Quote:
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.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License