- Preparing a batch command
- Auto-Executing Batch command
Alteryx users often find themselves cluttered with a lot of (.bak) files. When a workflow is overwritten, a backup file (.bak) is generated in the same directory with the same filename as that of the workflow. A (.bak) file actually stores the workflow information in an xml code. Although Alteryx Designer has a separate auto-recovery process to backup the workflows (Refer to Advanced User Settings ->Autorecover Options), this particular process of generating (.bak) files annoyed many users. Eventually users would then manually either delete or move those (.bak) files elsewhere.
Read this post to setup your automatic cleanup process so you won't have to manually move or delete (.bak) files the next time. Especially it's helpful for Alteryx Server Admin to effectively manage the machine’s resources and implement Best Practices. There can be several workarounds to automate this process, but here a simple way of doing it using a windows batch command.
Based on your purpose of usage, either you can create a batch command to move all the (.bak) files to a designated folder, or have them eliminated completely from the system. You can write the syntax in notepad and save it as a .txt file, finally change the file extension to .bat
The syntax for a batch command in order to move your (.bat) file is as below:
FOR /R %%a IN (*.bak) DO (MOVE /Y "%%a" "%cd%")
For Desktop usage, you can replace %cd% for your destination folder as shown below:
FOR /R %%a IN (*.bak) DO (MOVE /Y "%%a" "C:\Users\Laptop\Desktop\NEW\")
For Server usage, enable Admin Permissions and type the UNC Path of the destination folder as shown below:
FOR /R %%a IN (*.bak) DO (MOVE /Y "%%a" "\\Server\Machine\Drive\Folder_Name\")
The syntax for a batch command in order to delete your (.bat) file is as below:
DEL /S UNC_Path\*.bak
For Desktop usage, replace UNC_Path with your folder where the (.bak) files exist currently
DEL /S C:\Users\Laptop\Desktop\Workflows\*.bak
For Server usage, enable Admin Permissions and replace UNC_Path with your folder where the (.bak) files exist currently.
DEL /S \\Server\Machine\Drive\Folder_Name\*.bak
Once you have prepared the batch command, you can either use the Alteryx or Windows Task Scheduler to automate the process.
From the Alteryx Designer’s workflow configuration, you can add a new event. Add a run command and select the desired file. Finally setup the auto-scheduler for this particular workflow and run it on the Desktop or Server to clean-up the (.bak) files automatically. In case of the Server, you need to make sure that the particular workflow and gallery account has Superuser permissions to access the network path.
Windows Task Scheduler is located on the Control Panel, under Administrative Tools. From the task scheduler, you can register a new task and setup the necessary conditions, trigger etc. This will be an automated task which will run on the configured trigger.
To conclude, this post is particularly helpful to automatically clean-up (.bak) files and tidying up your work environment. Especially on the server, with too many users and each user having multiple folders, it is recommended to use an automated task to process all the (.bak) files at once. This may effectively improve the server performance.