Table of Contents

copytree

FreeSince 2.0.46

Description

The copytree command copies a file tree in the SOLIDWORKS PDM vault, with options to apply prefixes, suffixes, and other filters. This only works with assembly files.

Syntax

copytree (-search search_query_or_csv | -filePath assembly_file) -directory target_folder [-suffix value] [-prefix value] [-recursive] [-includedrawings] [-latest] [-csv report_path]

Parameters

Parameter Alias Required Description
-search No A normal search query, or a <Path.csv> query file, used to find files to copy.
-filePath No The source file or directory to copy.
-suffix No Adds a suffix to the copied files.
-prefix No Adds a prefix to the copied files.
-recursive No Copies files recursively from subdirectories.
-includedrawings No Includes associated drawing files in the copy operation.
-latest No Ensures the latest version of the files is copied.
-directory -dir No Specifies the target directory where the files will be copied.
-csv No Writes a CSV report for successful CopyTree operations.

More about parameters

  • csv: Writes a successful-operation report. The report's parent directory must already exist. Existing writable reports are replaced. Relative report paths use the current PDM directory.

Examples

Copy one assembly tree:

copytree -filePath "fidget spinner.sldasm" -suffix _ -directory "\new project"

Copy assemblies found by search:

copytree -search "*.sldasm" -includedrawings -directory "c:\export"

Copy parts found by a named search token:

copytree -search "Name=%.sldprt" -recursive -directory "C:\Export"

Copy parts using a simple wildcard query:

copytree -search "%.sldprt" -recursive -directory "C:\Export"

Copy assemblies from a CSV-backed search and write a report:

copytree -search "<C:\Temp\files.csv>" -directory "E:\Destination" -recursive -includedrawings -latest -csv "C:\Temp\copy-report.csv"

Write a report when copying one assembly:

copytree -filePath "Assembly.sldasm" -directory "E:\Destination" -csv "C:\Temp\copy-report.csv"

Search Input

The -search parameter supports normal search queries and CSV-backed query input.

copytree -search "Name=%.sldprt" -recursive -directory "C:\Export"
copytree -search "%.sldprt" -recursive -directory "C:\Export"
copytree -search "<C:\Temp\queries.csv>" -recursive -directory "C:\Export"

Without <Path.csv>, the value is treated as a normal search query. CSV input uses the first column and skips the header row.

Search behavior:

  • All matches are processed, including all matches for each CSV row.
  • Token assignments use =. Use Name=%, not Name-%.
  • Searches use the current PDM directory.
  • -recursive includes subfolders.

Automatic Helper Cleanup

After each successful CopyTree operation, PDMShell automatically attempts to terminate newly created AddInSrv.exe helper processes that match the installed PDM executable, current Windows user and session, and the copy-operation time window.

This cleanup has no parameter or setting. It applies to direct-file, normal-search, and CSV-driven copies.

Cleanup behavior:

  • Pre-existing helper processes are preserved.
  • Cleanup is skipped for failed copies.
  • Cleanup is skipped for overlapping CopyTree operations within the same process.
  • Cleanup failures are logged without marking an otherwise successful copy as failed.
Important

Run large CopyTree batches in an isolated session when possible. DCOM does not prove exclusive process ownership, so unrelated simultaneous PDM activity cannot always be distinguished from CopyTree helper activity.

CSV Report

The optional -csv parameter writes a successful-operation report for CopyTree calls that return without an exception.

SearchItem,SourcePath,DestinationDirectory
Part001,C:\Vault\Part001.sldprt,E:\Destination
Assembly002,C:\Vault\Assembly002.sldasm,E:\Destination
Column Meaning
SearchItem Original CSV first-column search value, or the ordinary search query. Blank for -filePath or unavailable search context.
SourcePath Full path of the root file passed to CopyTree.
DestinationDirectory Resolved destination folder, not the copied file's final name.

Reporting behavior:

  • One row is written per CopyTree call that returns without an exception.
  • References and drawings are not individually listed.
  • Multiple matches for one search item each receive a row.
  • Input order and duplicate search entries are preserved.
  • Failed calls are omitted; their errors remain in the command log.
  • Completed operations are still reported after handled failures or cancellation.
  • No matches produces a header-only report.
  • The report is UTF-8 and uses CSV escaping for commas, quotes, and line breaks.
  • The report's parent directory must already exist.
  • Existing writable reports are replaced.
  • No automatic vault add, checkout, or check-in is performed for the report.
Important

The CopyTree CSV report is a successful-operation report. It is not a verified inventory of every file physically copied.

Remarks

  • The -dir parameter specifies the target directory. If omitted, the current directory is used.
  • Use the recursive parameter to include all subdirectories in the operation.
  • The includedrawings parameter ensures that associated drawing files are included in the copy.
  • The latest parameter ensures that only the latest versions of files are copied.
  • When -search is used, all matches from every CSV search entry are processed. CSV parsing, duplicate handling, and reference-selection behavior are unchanged.
  • CopyTree reuses one vault connection and copy worker across a search batch, reduces UI updates, and keeps detailed per-file command logs.
  • Cancellation is checked between CopyTree calls. It does not interrupt an active native CopyTree call.