Synchronize and only change permissions to new files

Advertisement

info_you85
Joined:
Posts:
8

Synchronize and only change permissions to new files

Hello,

I made a script who synchronize a local folder to a remote folder: it works fine
After I execute a chmod 644 on all files with extensions *.pdf for example: it works but it take long time because it change the permissions for all files: the new ones and the olders who already have the good permissions.
Is it possible to "filter" the chmod only to the new files I just synchronized? Like files who are modifies under 24hours for examples?

Thanks

2023-04-27_08h42_19.png

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,478
Location:
Prague, Czechia

Re: Synchronize and only change permissions to new files

You can make synchronize command change permissions of the synchronized files:
synchronize remote ... -permissions=644
(it will also set permissions of newly directories – to 755).

Reply with quote

info_you85
Joined:
Posts:
8

Thanks for your reply.

I already try the -permissions but it doesn't work, I guess it's because I use FTP and not SFTP?
I will try again ;)

Reply with quote

info_you85
Joined:
Posts:
8

Does someone know if it's normal that the option -permission didn't work with he FTP connection?
I don't have choice to use SFTP connection for use this option?

Thanks

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,478
Location:
Prague, Czechia

Indeed, the -permissions works for SFTP and SCP only, as the documentation says:
https://winscp.net/eng/docs/scriptcommand_synchronize#permissions

With FTP, you would have to use WinSCP .NET assembly e.g. from PowerShell script. The script would have to iterate synchronized files and call respective FTP command (SITE CHMOD ...) to change the permissions for each of them (via Session.ExecuteCommand, as the .NET assembly does not expose the chmod functionality directly).

There's a guide for Converting Script to Code Based on .NET Assembly. Though in your case, it's probably straightforward.

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum