copy partial directory structure

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
OUrm7Vo2
Junior Member
Junior Member
Posts: 80
Joined: 2003-04-17, 18:50 UTC

copy partial directory structure

Post by *OUrm7Vo2 »

I want to copy only folders in a directory structure that contain the files filtered by 'only files of this type'. So if a subfolder contains a matching file type in the subfolder structure then the entire subfolder structure is created and the file copied. If a subfolder structure does not contain a matching file then that subfolder structure should not be created.

Can TC only create certain subfolders based on this requirement or will it always create the full directory structure?
Fla$her
Power Member
Power Member
Posts: 2385
Joined: 2020-01-18, 04:03 UTC

Re: copy partial directory structure

Post by *Fla$her »

TOTALCMD.CHM wrote:F5: Copy

In the field Only files of this type, you can define that only specific files should be copied.
Examples:
*.txt *.doc will copy only text and doc files (also applies to files in subdirs!)
*.* | *.bak *.old will copy everything except for bak and old files
*.* | somedir1\ somedir2\ will not copy files in subdirs named somedir1 and somedir2

The button "+ F8" allows you to define search filters, which offer more options which files should be copied, e.g. by size, date/time or via content plugins. You can also copy related files. For example, you would want to copy all jpg files, plus all RAW image files (.cr2), but only if there is a jpg file in the same directory. This can be done with the following selection string: *.jpg>*.cr2 . Note: The copy filter will only be applied to selected files, and to files in selected folders. Append |**\ to skip copying of empty folders.
Similar topic
Overquoting is evil! 👎
OUrm7Vo2
Junior Member
Junior Member
Posts: 80
Joined: 2003-04-17, 18:50 UTC

Re: copy partial directory structure

Post by *OUrm7Vo2 »

What if I wanted to copy only files in subdirs named somedir1 and somedir2?
User avatar
white
Power Member
Power Member
Posts: 4665
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: copy partial directory structure

Post by *white »

OUrm7Vo2 wrote: 2024-05-15, 10:02 UTC What if I wanted to copy only files in subdirs named somedir1 and somedir2?
You can use somedir1\ and somedir2\ as include masks, but note that this filters which subfolders are traversed into and is probably not what you want.
For example:

Code: Select all

file1 somedir1\ somedir2\ | **\
This means:
  1. Copy file1 if found
  2. Traverse into somedir1 and somedir2, if traversed into a folder continue with step 1
  • The last part:

    Code: Select all

    | **\
    means do not copy traversed folders (avoids creating empty folders)

You can however filter on a defined filter which has more possibilities. For example, when defining a filter use the plugin tab and check tc.fullname against a regular expression.
Post Reply