Scripts for taking action on Information Map data sets

Information Map enables you to take action on the data sets you identify via the 'export' to CSV funtionality and then executing a script against the exported file set. This post is a placeholder for sharing sample scripts. Upload any scripts as replies in this thread. If the scripts have come from any 3rd party source, do remember to include the attribution as to where they came from. Also feel free to share any best practises or hints and tips for taking action. 

3 Replies

Re: Scripts for taking action on Information Map data sets

Here is a PowerShell script to copy files identified by Information Map.

#USE AT OWN RISK. Veritas Technologies LLC provides no warranty of any kind.

$FileList = "C:\temp\VBSFiles-0001.txt"
$DestDir="c:\copydestination"

Get-Content $FileList | % {
# Create the destination folder path
$NewFolder = "$DestDir$(Split-Path $_ -Parent | Split-Path -NoQualifier)"

# Check if the path exsists - create if it doesn't exist
If(!(Test-Path $NewFolder)){
New-Item -ItemType Directory -Path $NewFolder -Force
}
# Copy the file to new location
Copy-Item $_ $NewFolder -Force
}

You will need to change the following variables to match your environment:

  • $FileList – Full path and file name to text file contain the list of items to copy
  • $DestDir – The destination path for the copied files

When executed, the script will automatically create the folder structure that currently exists on the source on the destination.  The script assumes that the current user has at least read access to the files and directories that will be copied. 

 

 

 

 

Highlighted

Re: Scripts for taking action on Information Map data sets

Here is a PowerShell script to move files identified by Information Map.

#USE AT OWN RISK. Veritas Technologies LLC provides no warranty of any kind.

$FileList = "C:\temp\LogFiles-0001.txt"
$DestDir="c:\movedfiles"

Get-Content $FileList | % {
# Create the destination folder path
$NewFolder = "$DestDir$(Split-Path $_ -Parent | Split-Path -NoQualifier)"

# Check if the path exsists - create if it doesn't exsist
If(!(Test-Path $NewFolder)){
New-Item -ItemType Directory -Path $NewFolder -Force
}
# Move the file to new location
Move-Item $_ $NewFolder -Force
}

You would need to change the following parameters to match your environment:

  • $FileList – Full path and file name to text file contain the list of items to move
  • $DestDir – The destination path for the moved files

When executed, the script will automatically create the folder structure that currently exists on the source on the destination.  The script assumes that the current user has read-write access to the source directories and files. 

Note:  As this is a move operation, the files will automatically be deleted from the source location.

Re: Scripts for taking action on Information Map data sets

Here is a PowerShell script to delete files identified by Information Map:

#USE AT OWN RISK. Veritas Technologies LLC provides no warranty of any kind.

$FileList = get-content "C:\temp\TmpFiles-0001.txt"

ForEach ($file in $FileList)
{
Remove-Item $file -Force
}

The administrator would need to change the following parameters to match their environment:

  • $FileList – Full path and file name to text file contain the list of items to delete

Once the script is executed, the script will delete the files listed in the file identified by the $FileList parameter.  The script also assumes that the current user has permissions to delete files.  It should be noted that the sample script will not delete the folder structure.  Back up any files before executing the script.