Skip to main content
Made sample code more readable by reformatting one really long line.
Source Link
Calak
  • 2.4k
  • 11
  • 19

script.py:

#!/usr/bin/python

import os

srcDir = os.getcwd()

dirName = 'target_directory'

dstDir = os.path.abspath(dirName)

def ignore_list(path, files):

    filesToIgnore = []

    for fileName in files:

        fullFileName = os.path.join(os.path.normpath(path), fileName)

        if (not os.path.isdir(fullFileName)
            and not fileName.endswith('pyc') and
            and not fileName.endswith('ui')
            and not fileName.endswith('txt') and
            and not fileName == '__main__.py'
            and not fileName == 'dcpp.bat'):

            filesToIgnore.append(fileName)

    return filesToIgnore

# start of script

shutil.copytree(srcDir, dstDir, ignore=ignore_list)

As shutil.copytree() has no option where I can give names for required files to copy like "ignore," I have modified the argument of ignore to give "required files to copy."

Review my code.

script.py:

#!/usr/bin/python

import os

srcDir = os.getcwd()

dirName = 'target_directory'

dstDir = os.path.abspath(dirName)

def ignore_list(path, files):

    filesToIgnore = []

    for fileName in files:

        fullFileName = os.path.join(os.path.normpath(path), fileName)

        if (not os.path.isdir(fullFileName) and not fileName.endswith('pyc') and
            not fileName.endswith('ui') and not fileName.endswith('txt') and
            not fileName == '__main__.py' and not fileName == 'dcpp.bat'):

            filesToIgnore.append(fileName)

    return filesToIgnore

# start of script

shutil.copytree(srcDir, dstDir, ignore=ignore_list)

As shutil.copytree() has no option where I can give names for required files to copy like "ignore," I have modified the argument of ignore to give "required files to copy."

Review my code.

script.py:

#!/usr/bin/python

import os

srcDir = os.getcwd()

dirName = 'target_directory'

dstDir = os.path.abspath(dirName)

def ignore_list(path, files):

    filesToIgnore = []

    for fileName in files:

        fullFileName = os.path.join(os.path.normpath(path), fileName)

        if (not os.path.isdir(fullFileName)
            and not fileName.endswith('pyc')
            and not fileName.endswith('ui')
            and not fileName.endswith('txt')
            and not fileName == '__main__.py'
            and not fileName == 'dcpp.bat'):

            filesToIgnore.append(fileName)

    return filesToIgnore

# start of script

shutil.copytree(srcDir, dstDir, ignore=ignore_list)

As shutil.copytree() has no option where I can give names for required files to copy like "ignore," I have modified the argument of ignore to give "required files to copy."

Review my code.

Made sample code more readable by reformatting one really long line.
Source Link

script.py:

#!/usr/bin/python

import os

srcDir = os.getcwd()

dirName = 'target_directory'

dstDir = os.path.abspath(dirName)

def ignore_list(path, files):

    filesToIgnore = []

    for fileName in files:

        fullFileName = os.path.join(os.path.normpath(path), fileName)

        if (not os.path.isdir(fullFileName) and not fileName.endswith('pyc') and
            not fileName.endswith('ui') and not fileName.endswith('txt') and
            not fileName == '__main__.py' and not fileName == 'dcpp.bat'):

            filesToIgnore.append(fileName)

    return filesToIgnore
 
# start of script

shutil.copytree(srcDir, dstDir, ignore=ignore_list)

As shutil.copytree() has no option where I can give names for required files to copy like "ignore," I have modified the argument of ignore to give "required files to copy."

Review my code.

script.py:

#!/usr/bin/python

import os

srcDir = os.getcwd()

dirName = 'target_directory'

dstDir = os.path.abspath(dirName)

def ignore_list(path, files):

    filesToIgnore = []

    for fileName in files:

        fullFileName = os.path.join(os.path.normpath(path), fileName)

        if not os.path.isdir(fullFileName) and not fileName.endswith('pyc') and not fileName.endswith('ui') and not fileName.endswith('txt') and not fileName == '__main__.py' and not fileName == 'dcpp.bat':

            filesToIgnore.append(fileName)

    return filesToIgnore
 
# start of script

shutil.copytree(srcDir, dstDir, ignore=ignore_list)

As shutil.copytree() has no option where I can give names for required files to copy like "ignore," I have modified the argument of ignore to give "required files to copy."

Review my code.

script.py:

#!/usr/bin/python

import os

srcDir = os.getcwd()

dirName = 'target_directory'

dstDir = os.path.abspath(dirName)

def ignore_list(path, files):

    filesToIgnore = []

    for fileName in files:

        fullFileName = os.path.join(os.path.normpath(path), fileName)

        if (not os.path.isdir(fullFileName) and not fileName.endswith('pyc') and
            not fileName.endswith('ui') and not fileName.endswith('txt') and
            not fileName == '__main__.py' and not fileName == 'dcpp.bat'):

            filesToIgnore.append(fileName)

    return filesToIgnore

# start of script

shutil.copytree(srcDir, dstDir, ignore=ignore_list)

As shutil.copytree() has no option where I can give names for required files to copy like "ignore," I have modified the argument of ignore to give "required files to copy."

Review my code.

Post Reopened by 200_success, amon, Jamal
deleted 4 characters in body; edited tags
Source Link
200_success
  • 144.2k
  • 22
  • 188
  • 473

script.py:

script.py:

#!/usr/bin/python

import os

srcDir = os.getcwd()

dirName = 'target_directory'

dstDir = os.path.abspath(dirName)

def ignore_list(path, files):

    filesToIgnore = []

    for fileName in files:

        fullFileName = os.path.join(os.path.normpath(path), fileName)

        if not os.path.isdir(fullFileName) and not fileName.endswith('pyc') and not fileName.endswith('ui') and not fileName.endswith('txt') and not fileName == '__main__.py' and not fileName == 'dcpp.bat':

            filesToIgnore.append(fileName)

    return filesToIgnore
 
# start of script

shutil.copytree(srcDir, dstDir, ignore=ignore_list)

As shutil.copytree() has no option where I can give names for required files to copy like "ignore," I have modified the argument of ignore to give "required files to copy."

Review my code.

script.py:

#!/usr/bin/python

import os

srcDir = os.getcwd()

dirName = 'target_directory'

dstDir = os.path.abspath(dirName)

def ignore_list(path, files):

    filesToIgnore = []

    for fileName in files:

        fullFileName = os.path.join(os.path.normpath(path), fileName)

        if not os.path.isdir(fullFileName) and not fileName.endswith('pyc') and not fileName.endswith('ui') and not fileName.endswith('txt') and not fileName == '__main__.py' and not fileName == 'dcpp.bat':

            filesToIgnore.append(fileName)

    return filesToIgnore
 
# start of script

shutil.copytree(srcDir, dstDir, ignore=ignore_list)

As shutil.copytree() has no option where I can give names for required files to copy like "ignore," I have modified the argument of ignore to give "required files to copy."

Review my code.

script.py:

#!/usr/bin/python

import os

srcDir = os.getcwd()

dirName = 'target_directory'

dstDir = os.path.abspath(dirName)

def ignore_list(path, files):

    filesToIgnore = []

    for fileName in files:

        fullFileName = os.path.join(os.path.normpath(path), fileName)

        if not os.path.isdir(fullFileName) and not fileName.endswith('pyc') and not fileName.endswith('ui') and not fileName.endswith('txt') and not fileName == '__main__.py' and not fileName == 'dcpp.bat':

            filesToIgnore.append(fileName)

    return filesToIgnore
 
# start of script

shutil.copytree(srcDir, dstDir, ignore=ignore_list)

As shutil.copytree() has no option where I can give names for required files to copy like "ignore," I have modified the argument of ignore to give "required files to copy."

Review my code.

edited tags
Link
Patrick
  • 369
  • 2
  • 3
  • 11
Loading
added 94 characters in body; edited title
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237
Loading
changed the question and this is my working code
Source Link
Patrick
  • 369
  • 2
  • 3
  • 11
Loading
deleted 54 characters in body
Source Link
Patrick
  • 369
  • 2
  • 3
  • 11
Loading
Post Closed as "Not suitable for this site" by Jamal
added 70 characters in body
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237
Loading
Source Link
Patrick
  • 369
  • 2
  • 3
  • 11
Loading