Salesforce

WorldServer - how to delete Temp file on the server excluding subfolders such as 'ftsserver' or 'Attributes'

« Go Back

Information

 
TitleWorldServer - how to delete Temp file on the server excluding subfolders such as 'ftsserver' or 'Attributes'
URL Name000015284
SummaryTemp files and folders can usually be deleted shortly after they have been created by WorldServer while creating a project or after uploading Return packages etc. However, this Temp folder mostly also contain folders that should not be deleted or deleted separately according to different criteria. How can I delete only the temp files and folders that are not needed while excluding the ones that are needed? This can be achieved by running a PowerShell script that excludes the deletion to be run on certain folders inside the main directory, i.e. Temp. Also, the script copies the files on a different location and folder first as a security measure and back up. This folder can be deleted permanently later. This article provides the script.
Scope/EnvironmentWorldServer
Question
On the WorldServer server, it is common to run out of space at times. Often, the space is taken by Temp files placed under the WorldServer directory, for instance under:

C:\ProgramFiles\Idiom\WordServer\Temp

Temp files and folders can usually be deleted shortly after they have been created by WorldServer while creating a project or after uploading Return packages etc. However, this Temp folder mostly also contain folders that should not be deleted or deleted separately according to different criteria. One of these folder is the ftsserver, which contains the DependencyFiles folder. 
Another folder that is placed by default under Temp is attributes and also SystemMonitor. How can I delete only the temp files and folders that are not needed while excluding the ones that are needed?
Answer
This can be achieved by running a PowerShell script that excludes the deletion to be run on certain folders inside the main directory, i.e. Temp. Also, the script copies the files on a different location and folder first as a security measure and backup. This folder can be deleted permanently later after reviewing that the result is as expected. Here is the script:

Get-Childitem "W:\WorldServer\temp" -Recurse | ? { $_.FullName -inotmatch 'ftsserver' } | Where {$_.LastWriteTime -le "Friday, November 01, 2022 00:00:00 AM"} | move-item -destination "W:\TEMP-Del-After30032022\"

For Logs :

Get-Childitem "W:\WorldServer\logs" -Recurse } | Where {$_.LastWriteTime -le "Friday, November 01, 2022 00:00:00 AM"} | move-item -destination "W:\TEMP-Del-After30032022\"

Reference
Attachment 1 
Attachment 2 
Attachment 3 
Attachment 4 
Attachment 5 

Powered by