Automatically MOVE or DELETE your (.bak) files

2020.03.13

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

(日本語版はこちらから)

Contents

  1. Introduction
  2. Preparing a batch command
    1. Batch command for moving
    2. Batch command for deletion
  3. Auto-Executing Batch command
    1. Using Alteryx
    2. Using Windows Task Scheduler
  4. Conclusion

Introduction

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.

Preparing a 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

Batch command for moving

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\")

Batch command for deletion

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

Auto-Executing Batch command

Once you have prepared the batch command, you can either use the Alteryx or Windows Task Scheduler to automate the process.

Using Alteryx

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.

Using Windows Task Scheduler

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.

Conclusion

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.