Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have Python version 3.7.1.

I would like to sync files with extension .835 in the source directory to the target directory. Why is this code pulling over all files?

import dirsync
dirsync.sync(source,destination,'sync',verbose=True,only='.*\.835$')

I have also tried the --include option and pattern like this:

import dirsync
pattern = r'.*\.835$'
dirsync.sync(source,destination,'sync',verbose=True,include=pattern)

How do I solve this problem?

There is nothing wrong with your pattern. The issue must have something to do with dirsync – emsimpson92 Dec 10, 2018 at 21:23
import dirsync
pattern = r'.*\.835$',
dirsync.sync(source, destination, 'sync', verbose=True, include=pattern)
import dirsync
dirsync.sync(source, destination, 'sync', verbose=True, include=(r'^.*\.wav$',))

If you are still having issues, the dirsync example scripts should point you in the right direction: https://bitbucket.org/tkhyn/dirsync/src/default/tests/regexfilters.py

I would also make sure you know what the various options do. Depending on the use case "only" may be more useful than "include"

You can find the documentation here: https://bitbucket.org/tkhyn/dirsync/src/default/

--only, -o patterns

Regex patterns to include (exclude every other)

--exclude, -e patterns

Regex patterns to exclude

--include, -i patterns

Regex patterns to include (with precedence over excludes)

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.