File operations

<< Click to Display Table of Contents >>

Navigation:  Using the TreeSize File Search >

File operations

This function enables you to move all checked files and folders in the search result lists to a destination of your choice, archive them in a ZIP file, delete them, or process the files. This function is accessible at "Home > Move items".

TreeSize-Move_Dialog

 

Additional options enable you to configure the file system operations to suit your needs. In this section all available operations and options are listed and described.

 

File Operation:

Delete Items

Deletes all marked files (a security prompt has to be confirmed). If the move option "Move to Recycle Bin" is activated, the files will be moved to the Recycle Bin. Otherwise they will be deleted from the hard disk. Attention: Deletion without setting the corresponding check box cannot be undone without further notice.

Move Items

Moves the selected files to the specified path. Optionally, a shortcut or a link can be created at the original location, each pointing to the new position of the moved object. If desired, the security attributes can also be copied. If this does not happen, the moved files inherit their security attributes (as usual) from the higher-level elements.

Copy Items

Copies the selected files to the specified path. If desired, the security attributes can also be copied. If this does not happen, the moved files inherit their security attributes (as usual) from the higher-level elements.

Zip items

Moves selected files to the specified ZIP archive.

Note: If ZIP files contain Unicode file or folder names, they can only be correctly extracted with a Unicode-compatible ZIP software such as WinRAR, WinZip or 7-Zip (see "Unicode Zip files").

Pass items to executable as parameter

An executable file will be called for every checked file and the full path of the file will be passed as parameter on the command line. The executable file may also be a batch, a PowerShell script or VBScript file (or something similar). The Windows Scripting FileSystemObject offers powerful and easy-to-use capabilities for file system and path operations. Please find an eaxmaple for the use of a PowerShell Script below.

Options:

Move to Recyle Bin (if available)

Here you can specify whether the selected items should be moved to the recycle bin or deleted directly from the hard disk.

Note: This option is only available for the "Delete" operation.

Skip/Rename/Replace/Replace only older existing files

Configure how TreeSize will handle name collisions in the move destination, in case a file with the same name already exists. You can skip the existing files, replace them by the new one, or rename the existing files.

Please note: Only available for "Zip" and "Move to path" operation. Not supported when burning to an optical medium.

Delete empty directories after the operation

Deletes all folders that have been emptied due to this move operation.

Preserve directory structure, starting from level x

Use this option to configure the level of parent directories to preserve. The first x parent directories will not be included in the destination path.

For example, when moving a file "C:\Users\Smith\My Document.doc" to destination "D:\Obsolete Files" you will get the following results:
x = 0 > "D:\Obsolete Files\C\Users\Smith\My Document.doc"
x = 1 > "D:\Obsolete Files\Users\Smith\My Document.doc"
x = 2 > "D:\Obsolete Files\Smith\My Document.doc"

Please note: Only available for "Move" and "Copy" operation.

Keep original items after zipping

Activate this option so that the original files are not deleted after copying to a zip file.

Note: This option is only available for the "Zip" operation.

Preserve permissions of the original items

If this option is activated, the permissions of the original file will be used for the file in the new location.

Please note: Only available for "Move" and "Copy" operation. Not supported when burning to an optical medium.

Leave shortcut/link at original location pointing to new location

If this option is activated, a shortcut or link will be created at the original location pointing to the location the file has been moved to. If you choose to leave a link and the files are on the same partition, an NTFS hardlink will be created. If the creation of a hardlink is not possible, a symbolic link is used (Windows Vista and later). If a symbolic link cannot be created, a Windows shortcut will be used as a fallback.

Please note: Only available for "Move" operation.

Logging:

Log performed operations to:

Produces a log file with a name of your choice under the path of your choice. Environment variables like %DATE% or %TIME% can be used in the file name.

Create Undo script

Creates a batch file which can be run after the operation was finished to undo the changes applied during this operation.

Please note: Only available for "Move" and "Copy" operation. Not supported when burning to an optical medium.

PowerShell Scripts using the example of SharePoint

We would like to show you in a practical example the use of a PowerShell script with the TreeSize File Search. The task is to prepare thousands of documents for uploading them to a SharePoint server. The problem is that certain characters are not allowed in filenames on SharePoint, that are valid in the normal file system and that are commonly used. Using a regular expression, which you can find in the chapter Regular Expressions, it is easy to find all files that violate the SharePoint naming rules. When the search is finished, please choose in the dialog to move the checked files to pass them to an executable. As executable please choose this PowerShell script, which you have previously save e.g. as  "SharePointRename.ps1":

Param([string]$filepath="")

[char[]]$illegal = "~", "#", "%", "&", "*", "{", "}", "\", ":", "<", ">", "?", "/", "|"

$replacement = "-"

$filepathNew = [io.path]::GetFileName($filepath)

foreach($char in $illegal){$filepathNew = $filepathNew.Replace($char, $replacement)}

Rename-Item $filepath $filepathNew

 

The script can be easily adapted or extended for further use cases.

Logging

Tip: Logging your move, archive, or delete operations provides an clarity and improves security for your system maintenance and is highly recommended.

The log produced by TreeSize shows all the necessary details to trace a maintenance act. The file will be saved in plain text format. A typical log file looks like this :

Starting file operation at 28.08.13 16:46.

Moving the following objects to "C:\Obsolete":

"D:\Data\BGInfo.bmp" => "C:\Obsolete\D\Data\BGInfo.bmp"

"D:\Data\readme.txt" => "C:\Obsolete\D\Data\readme.txt"

"D:\Data\Help\article.chm" => "C:\Obsolete\D\Data\Help\article.chm"

Finished file operation at 28.08.13 16:46.

Affected objects: 3 | Failed objects: 0 | Invalid objects: 0

 

Freed Space: 114170 Bytes (111 KB)