Topic "PRoblem with file mask <D"

Author Message
Shibbard50
[View user's profile]
Donor
Joined: 2017-06-23
Posts: 3
I have a seemingly simple task that I am not able to make work: log in to FTP and delete files in folder older than 120 days. Here is the script I have, based on your examples and generated from the GUI:

Code:
@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\Capture\WinSCP.log" /ini=nul ^
  /command ^
    "open scp://xxx@xxx.xxx.xxx.xxx/ -hostkey=""ssh-ed25519 256 2c:3b:da:f4:2e:9f:7d:cd:3d:48:11:ef:ce:cc:e8:23"" -privatekey=""N:\xxx"" -rawsettings AuthKIPassword=0 TunnelPublicKeyFile=""xxx""" ^
    "rm /xxx/xxx/ArtUploadArchive/*<120"
    "exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)

exit /b %WINSCP_RESULT%


I definitely have files in that folder older than 120 days, just a few but they are there. When it didn't work, I tried changing the mask to a filename with wildcard ("rm /xxx/xxx/ArtUploadArchive/*.psf", and the message said 'No file matching *.psf found'.

However, when I changed it to "rm /xxx/xxx/ArtUploadArchive/ABbanner.psf", that file was deleted. This file is older than 120 days, fwiw.

What am I missing?
Advertisements
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27059
Location: Prague, Czechia
It's *<120D, not *<120.

See https://winscp.net/eng/docs/file_mask#size_time
Shibbard50
[View user's profile]
Donor
Joined: 2017-06-23
Posts: 3
Ugh, sorry! that was a copy/paste error, I am using the syntax <120D.

Any other ideas of why this is not working? Please note my comment that the filter also didn't work with the mast *.psf but did work when I made it the single filename ABBanner.psf...

I've attached a log file from running today minus identifying informaiton. Also a screen shot of the filezilla listing showing files that are <120D.

thanks!
120D.PNG (31.95 KB)

Description: (none)

120D.PNG

WinSCP.log (14.4 KB) [Download]

Description: (none)

martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27059
Location: Prague, Czechia
The /home/forge/ArtUploadArchive is actually a symlink, right?
WinSCP gets confused by that.
Why do you actually use SCP protocol? With SFTP protocol there should be no problem. Or use a final path, instead of the symlink.
Shibbard50
[View user's profile]
Donor
Joined: 2017-06-23
Posts: 3
Yes, it's a symlink, I wondered if that was part of the problem. I'm not sure why I used SCP in the original script - I generated the code from my original profile, I'm learning as I go and that was probably the first connection I had success with. Switching to SFTP solved this issue for me, thanks very much! this is a very nice utility.
Advertisements

You can post new topics in this forum

Search

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