Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Delete Destination Folder and Move Source Folder Contents

Description
This script will IRREVERSIBLY delete the destination folder (line 14), move the contents of the source folder (line 13) to the destination folder, then delete the empty source folder. This script is destructive so please test and use at your own risk!
Language
C#.net
Minimum Version
Created By
Keith Lammers (BFS)
Contributors
-
Date Created
Jan 31, 2022
Date Last Modified
Jan 31, 2022

Scripted Function (Macro) Code

using System;
using System.Drawing;
using System.IO;

public static class DisplayFusionFunction
{
	public static void Run(IntPtr windowHandle)
	{		
		// Set the source and destination folders here
		string sourceFolder = @"C:\path\to\source";
		string destinationFolder = @"D:\path\to\destination";
		
		// Comment out this line and uncomment the next line if you don't want to be prompted when running the script
		bool confirm = BFS.Dialog.GetUserConfirm("This script will IRREVERSIBLY delete \"" + destinationFolder + "\" and then move \"" + sourceFolder + "\" to \"" + destinationFolder + "\". Are you sure you would like to continue?");
		// bool confirm = true;
		
		if (confirm)
		{		
			// Delete the destination directory (this is recursive, will delete the folder and all sub-folders!)
			Directory.Delete(destinationFolder, true);
		
			// Move the source to the destination (note this moves the contents of the source folder into the destination folder,
			// it does not move the source folder itself but it will remove the empty source folder when done)
			Directory.Move(sourceFolder, destinationFolder);
		}
		else
		{
			return;	
		}
	}	
}