Community forum

Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


MRomer
2021-04-05T20:47:22Z
Using 9.6.5 on Windows 2019 Server.

I created a task to delete files older than five days in a folder. I want to exclude files that have their archive bit set so that I do not delete a file that has not been backed up. However, I do not seem to be able to exclude files by the Archive attribute.

In the Delete File(s) > File Filter > Attributes tab, if I uncheck "Include all attributes" and only check Include attribute(s) > Archive, I get the expected list of files with their archive bit set. However, if I only have Exclude attribute(s) > Archive checked, I get an empty list.

How do I get a list of all files except those with their archive bit set? I'm going to write a PowerShell script to do the work, but I'd rather be able to do this within the Delete File(s) task.
Sponsor
Forum information
Support
2021-04-23T12:55:14Z
Originally Posted by: MRomer 

Using 9.6.5 on Windows 2019 Server.

I created a task to delete files older than five days in a folder. I want to exclude files that have their archive bit set so that I do not delete a file that has not been backed up. However, I do not seem to be able to exclude files by the Archive attribute.

In the Delete File(s) > File Filter > Attributes tab, if I uncheck "Include all attributes" and only check Include attribute(s) > Archive, I get the expected list of files with their archive bit set. However, if I only have Exclude attribute(s) > Archive checked, I get an empty list.

How do I get a list of all files except those with their archive bit set? I'm going to write a PowerShell script to do the work, but I'd rather be able to do this within the Delete File(s) task.



Thanks, this seem to be a bug. Ive notified our developers about it and we will let you know when it's fixed.

I sincerely apologize for the late forum response.

As a temporary work around you could probably use a Flow function instead for this, like if the output contains any *.zip or whatever archive you use, stop the job (first use a list files task, then a delete files)
Michael
Support
http://www.visualcron.com 

Please like  VisualCron on facebook!
MRomer
2021-04-23T14:10:57Z
Thanks, Michael. I've got it working with a PowerShell script for now. Here it is in case anyone is interested:

$archiveBit = [System.IO.FileAttributes]::Archive ;
$endDate = ((Get-Date).AddDays(-{JOB(Active|Variable|bakDaysToKeep)})) ;
$fileList = (gci -Path "{JOB(Active|Variable|workingFolder)}" -Filter '*.bak' -Recurse | ? {($_.LastWriteTime -lt $endDate) -and (($_.Attributes -band $archiveBit) -ne $archiveBit)}).FullName ;
foreach ($fileName in $fileList) {
    Remove-Item -Path $fileName ;
    Write-Output $fileName
}
Support
2021-04-23T14:24:57Z
Originally Posted by: MRomer 

Thanks, Michael. I've got it working with a PowerShell script for now. Here it is in case anyone is interested:

$archiveBit = [System.IO.FileAttributes]::Archive ;
$endDate = ((Get-Date).AddDays(-{JOB(Active|Variable|bakDaysToKeep)})) ;
$fileList = (gci -Path "{JOB(Active|Variable|workingFolder)}" -Filter '*.bak' -Recurse | ? {($_.LastWriteTime -lt $endDate) -and (($_.Attributes -band $archiveBit) -ne $archiveBit)}).FullName ;
foreach ($fileName in $fileList) {
    Remove-Item -Path $fileName ;
    Write-Output $fileName
}



Great!

May i ask why you don't use the file exclusion in the task and just exclude archived files, liked *.zip etc?
Michael
Support
http://www.visualcron.com 

Please like  VisualCron on facebook!
bweston
2021-04-26T21:13:35Z
Presumably because that isn't what the archive bit means.

https://en.wikipedia.org/wiki/Archive_bit 
Support
2021-04-27T09:29:44Z
Originally Posted by: bweston 

Presumably because that isn't what the archive bit means.

https://en.wikipedia.org/wiki/Archive_bit 



Thanks for the information!
Michael
Support
http://www.visualcron.com 

Please like  VisualCron on facebook!
Support
2021-05-05T12:40:04Z
Originally Posted by: MRomer 

Using 9.6.5 on Windows 2019 Server.

I created a task to delete files older than five days in a folder. I want to exclude files that have their archive bit set so that I do not delete a file that has not been backed up. However, I do not seem to be able to exclude files by the Archive attribute.

In the Delete File(s) > File Filter > Attributes tab, if I uncheck "Include all attributes" and only check Include attribute(s) > Archive, I get the expected list of files with their archive bit set. However, if I only have Exclude attribute(s) > Archive checked, I get an empty list.

How do I get a list of all files except those with their archive bit set? I'm going to write a PowerShell script to do the work, but I'd rather be able to do this within the Delete File(s) task.



We aren't able to reproduce this: https://www.screencast.com/t/UN0rZtz0jcp 
Do the files have other attributes than Archive, if so what attributes?
Michael
Support
http://www.visualcron.com 

Please like  VisualCron on facebook!
Scroll to Top