Copying files locally with rsync and subprocess












2












$begingroup$


I have Python code to copy the Files locally on the Server from one Directory to another using rsync and subprocess module, this is just in continuation of the post from this post where I tried to get various insight but opted to use below code finally.



Please advise if this further can be improved or optimized in pythonic way and help to provide your esteemed reviews please.



#!/bin/python3
import os
import glob
import datetime
import subprocess

def Copy_Logs():
# Variable Declaration to get the month and Curr_date_month
Info_month = datetime.datetime.now().strftime("%B")
Curr_date_month = datetime.datetime.now().strftime("%b_%d_%y")
Sourcedir = "/data1/logs"
Destdir = "/data2/logs/"
###### End of your variable section #######################
# The result of the below glob _is_ a full path
for filename in glob.glob("{2}/{0}/{1}/*.txt".format(Info_month, Curr_date_month, Sourcedir)):
if os.path.getsize(filename) > 0:
if not os.path.exists(Destdir + os.path.basename(filename)):
subprocess.call(['rsync', '-avz', '--min-size=1', filename, Destdir ])

if __name__ == '__main__':
Copy_Logs()









share|improve this question









New contributor




krock1516 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$

















    2












    $begingroup$


    I have Python code to copy the Files locally on the Server from one Directory to another using rsync and subprocess module, this is just in continuation of the post from this post where I tried to get various insight but opted to use below code finally.



    Please advise if this further can be improved or optimized in pythonic way and help to provide your esteemed reviews please.



    #!/bin/python3
    import os
    import glob
    import datetime
    import subprocess

    def Copy_Logs():
    # Variable Declaration to get the month and Curr_date_month
    Info_month = datetime.datetime.now().strftime("%B")
    Curr_date_month = datetime.datetime.now().strftime("%b_%d_%y")
    Sourcedir = "/data1/logs"
    Destdir = "/data2/logs/"
    ###### End of your variable section #######################
    # The result of the below glob _is_ a full path
    for filename in glob.glob("{2}/{0}/{1}/*.txt".format(Info_month, Curr_date_month, Sourcedir)):
    if os.path.getsize(filename) > 0:
    if not os.path.exists(Destdir + os.path.basename(filename)):
    subprocess.call(['rsync', '-avz', '--min-size=1', filename, Destdir ])

    if __name__ == '__main__':
    Copy_Logs()









    share|improve this question









    New contributor




    krock1516 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$















      2












      2








      2





      $begingroup$


      I have Python code to copy the Files locally on the Server from one Directory to another using rsync and subprocess module, this is just in continuation of the post from this post where I tried to get various insight but opted to use below code finally.



      Please advise if this further can be improved or optimized in pythonic way and help to provide your esteemed reviews please.



      #!/bin/python3
      import os
      import glob
      import datetime
      import subprocess

      def Copy_Logs():
      # Variable Declaration to get the month and Curr_date_month
      Info_month = datetime.datetime.now().strftime("%B")
      Curr_date_month = datetime.datetime.now().strftime("%b_%d_%y")
      Sourcedir = "/data1/logs"
      Destdir = "/data2/logs/"
      ###### End of your variable section #######################
      # The result of the below glob _is_ a full path
      for filename in glob.glob("{2}/{0}/{1}/*.txt".format(Info_month, Curr_date_month, Sourcedir)):
      if os.path.getsize(filename) > 0:
      if not os.path.exists(Destdir + os.path.basename(filename)):
      subprocess.call(['rsync', '-avz', '--min-size=1', filename, Destdir ])

      if __name__ == '__main__':
      Copy_Logs()









      share|improve this question









      New contributor




      krock1516 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      I have Python code to copy the Files locally on the Server from one Directory to another using rsync and subprocess module, this is just in continuation of the post from this post where I tried to get various insight but opted to use below code finally.



      Please advise if this further can be improved or optimized in pythonic way and help to provide your esteemed reviews please.



      #!/bin/python3
      import os
      import glob
      import datetime
      import subprocess

      def Copy_Logs():
      # Variable Declaration to get the month and Curr_date_month
      Info_month = datetime.datetime.now().strftime("%B")
      Curr_date_month = datetime.datetime.now().strftime("%b_%d_%y")
      Sourcedir = "/data1/logs"
      Destdir = "/data2/logs/"
      ###### End of your variable section #######################
      # The result of the below glob _is_ a full path
      for filename in glob.glob("{2}/{0}/{1}/*.txt".format(Info_month, Curr_date_month, Sourcedir)):
      if os.path.getsize(filename) > 0:
      if not os.path.exists(Destdir + os.path.basename(filename)):
      subprocess.call(['rsync', '-avz', '--min-size=1', filename, Destdir ])

      if __name__ == '__main__':
      Copy_Logs()






      python python-3.x






      share|improve this question









      New contributor




      krock1516 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      krock1516 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 8 mins ago









      Jamal

      30.3k11116226




      30.3k11116226






      New contributor




      krock1516 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 13 hours ago









      krock1516krock1516

      1113




      1113




      New contributor




      krock1516 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      krock1516 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      krock1516 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          1 Answer
          1






          active

          oldest

          votes


















          1












          $begingroup$

          You're calling now() twice - what will happen if the month changes between those two calls?



          Your code skips all files that exist, even though your linked question indicates that you need to update changed files.



          Your code checks that file is non-empty, but rsync is already doing this for you with --min-size=1.



          More generally, before you code up file-sync logic, it's best to read the rsync man page and see if your problem is already solved. Syncing files is a task full of corner cases and gotchas; life is too short for you to find them all. Just let rsync take care of it, whenever possible.



          The code below will update changed files while skipping unchanged files (as in your problem description). If you want to copy only new, non-existing files (as in your posted code), add --ignore-existing to the rsync options.



          import datetime
          import subprocess

          def Copy_Logs():
          Sourcedir = datetime.datetime.now().strftime("/data1/logs/%B/%b_%d_%y/")
          Destdir = "/data2/logs/"
          subprocess.call(['rsync', '-avz', '--min-size=1', '--include=*.txt', '--exclude=*', Sourcedir, Destdir ])





          share|improve this answer









          $endgroup$









          • 1




            $begingroup$
            This is a good answer! I'd recommend using PEP8 names though (copy_logs, source_dir, and dest_dir). It may also be prudent to note that you may be able to achieve this with a bash oneliner like rsync -avz --min-size=1 --include=*.txt --exclude=* /data/logs/$(date "+%B/%b_%d_%y/") /data2/logs/. Don't pull out Python when you don't need to!
            $endgroup$
            – Bailey Parker
            3 hours ago










          • $begingroup$
            If this isn't part of some larger Python project, you're absolutely right and there's no reason to use more than rsync and a shell. I will point out that your one-liner should quote the wildcards (yes, they'll almost never get interpolated by the shell as-is, but will it ever be baffling on the day that you have a file named --exclude=!) and doesn't need to quote the date format: rsync -avz --min-size=1 --include="*.txt" --exclude="*" /data1/logs/$(date +%B/%b_%d_%y/) /data2/logs/
            $endgroup$
            – Oh My Goodness
            2 hours ago












          • $begingroup$
            @OhMyGoodness, thanks for giving the nice and precise details, However, current code I have do not skips all the files it only skips the empty files as I test the code by running it on my data but its current not to use own method while rsync is taking care that already.
            $endgroup$
            – krock1516
            28 mins ago












          • $begingroup$
            @BaileyParker, many thanks for a suggesting a nice one liner i'll keep that handy though.
            $endgroup$
            – krock1516
            26 mins ago










          • $begingroup$
            @krock1516 I don't understand how this doesn't skip existing files. What does if not os.path.exists(Destdir + os.path.basename(filename)): do? It tests that the file does not exist...
            $endgroup$
            – Oh My Goodness
            13 mins ago











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "196"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          krock1516 is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f212074%2fcopying-files-locally-with-rsync-and-subprocess%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1












          $begingroup$

          You're calling now() twice - what will happen if the month changes between those two calls?



          Your code skips all files that exist, even though your linked question indicates that you need to update changed files.



          Your code checks that file is non-empty, but rsync is already doing this for you with --min-size=1.



          More generally, before you code up file-sync logic, it's best to read the rsync man page and see if your problem is already solved. Syncing files is a task full of corner cases and gotchas; life is too short for you to find them all. Just let rsync take care of it, whenever possible.



          The code below will update changed files while skipping unchanged files (as in your problem description). If you want to copy only new, non-existing files (as in your posted code), add --ignore-existing to the rsync options.



          import datetime
          import subprocess

          def Copy_Logs():
          Sourcedir = datetime.datetime.now().strftime("/data1/logs/%B/%b_%d_%y/")
          Destdir = "/data2/logs/"
          subprocess.call(['rsync', '-avz', '--min-size=1', '--include=*.txt', '--exclude=*', Sourcedir, Destdir ])





          share|improve this answer









          $endgroup$









          • 1




            $begingroup$
            This is a good answer! I'd recommend using PEP8 names though (copy_logs, source_dir, and dest_dir). It may also be prudent to note that you may be able to achieve this with a bash oneliner like rsync -avz --min-size=1 --include=*.txt --exclude=* /data/logs/$(date "+%B/%b_%d_%y/") /data2/logs/. Don't pull out Python when you don't need to!
            $endgroup$
            – Bailey Parker
            3 hours ago










          • $begingroup$
            If this isn't part of some larger Python project, you're absolutely right and there's no reason to use more than rsync and a shell. I will point out that your one-liner should quote the wildcards (yes, they'll almost never get interpolated by the shell as-is, but will it ever be baffling on the day that you have a file named --exclude=!) and doesn't need to quote the date format: rsync -avz --min-size=1 --include="*.txt" --exclude="*" /data1/logs/$(date +%B/%b_%d_%y/) /data2/logs/
            $endgroup$
            – Oh My Goodness
            2 hours ago












          • $begingroup$
            @OhMyGoodness, thanks for giving the nice and precise details, However, current code I have do not skips all the files it only skips the empty files as I test the code by running it on my data but its current not to use own method while rsync is taking care that already.
            $endgroup$
            – krock1516
            28 mins ago












          • $begingroup$
            @BaileyParker, many thanks for a suggesting a nice one liner i'll keep that handy though.
            $endgroup$
            – krock1516
            26 mins ago










          • $begingroup$
            @krock1516 I don't understand how this doesn't skip existing files. What does if not os.path.exists(Destdir + os.path.basename(filename)): do? It tests that the file does not exist...
            $endgroup$
            – Oh My Goodness
            13 mins ago
















          1












          $begingroup$

          You're calling now() twice - what will happen if the month changes between those two calls?



          Your code skips all files that exist, even though your linked question indicates that you need to update changed files.



          Your code checks that file is non-empty, but rsync is already doing this for you with --min-size=1.



          More generally, before you code up file-sync logic, it's best to read the rsync man page and see if your problem is already solved. Syncing files is a task full of corner cases and gotchas; life is too short for you to find them all. Just let rsync take care of it, whenever possible.



          The code below will update changed files while skipping unchanged files (as in your problem description). If you want to copy only new, non-existing files (as in your posted code), add --ignore-existing to the rsync options.



          import datetime
          import subprocess

          def Copy_Logs():
          Sourcedir = datetime.datetime.now().strftime("/data1/logs/%B/%b_%d_%y/")
          Destdir = "/data2/logs/"
          subprocess.call(['rsync', '-avz', '--min-size=1', '--include=*.txt', '--exclude=*', Sourcedir, Destdir ])





          share|improve this answer









          $endgroup$









          • 1




            $begingroup$
            This is a good answer! I'd recommend using PEP8 names though (copy_logs, source_dir, and dest_dir). It may also be prudent to note that you may be able to achieve this with a bash oneliner like rsync -avz --min-size=1 --include=*.txt --exclude=* /data/logs/$(date "+%B/%b_%d_%y/") /data2/logs/. Don't pull out Python when you don't need to!
            $endgroup$
            – Bailey Parker
            3 hours ago










          • $begingroup$
            If this isn't part of some larger Python project, you're absolutely right and there's no reason to use more than rsync and a shell. I will point out that your one-liner should quote the wildcards (yes, they'll almost never get interpolated by the shell as-is, but will it ever be baffling on the day that you have a file named --exclude=!) and doesn't need to quote the date format: rsync -avz --min-size=1 --include="*.txt" --exclude="*" /data1/logs/$(date +%B/%b_%d_%y/) /data2/logs/
            $endgroup$
            – Oh My Goodness
            2 hours ago












          • $begingroup$
            @OhMyGoodness, thanks for giving the nice and precise details, However, current code I have do not skips all the files it only skips the empty files as I test the code by running it on my data but its current not to use own method while rsync is taking care that already.
            $endgroup$
            – krock1516
            28 mins ago












          • $begingroup$
            @BaileyParker, many thanks for a suggesting a nice one liner i'll keep that handy though.
            $endgroup$
            – krock1516
            26 mins ago










          • $begingroup$
            @krock1516 I don't understand how this doesn't skip existing files. What does if not os.path.exists(Destdir + os.path.basename(filename)): do? It tests that the file does not exist...
            $endgroup$
            – Oh My Goodness
            13 mins ago














          1












          1








          1





          $begingroup$

          You're calling now() twice - what will happen if the month changes between those two calls?



          Your code skips all files that exist, even though your linked question indicates that you need to update changed files.



          Your code checks that file is non-empty, but rsync is already doing this for you with --min-size=1.



          More generally, before you code up file-sync logic, it's best to read the rsync man page and see if your problem is already solved. Syncing files is a task full of corner cases and gotchas; life is too short for you to find them all. Just let rsync take care of it, whenever possible.



          The code below will update changed files while skipping unchanged files (as in your problem description). If you want to copy only new, non-existing files (as in your posted code), add --ignore-existing to the rsync options.



          import datetime
          import subprocess

          def Copy_Logs():
          Sourcedir = datetime.datetime.now().strftime("/data1/logs/%B/%b_%d_%y/")
          Destdir = "/data2/logs/"
          subprocess.call(['rsync', '-avz', '--min-size=1', '--include=*.txt', '--exclude=*', Sourcedir, Destdir ])





          share|improve this answer









          $endgroup$



          You're calling now() twice - what will happen if the month changes between those two calls?



          Your code skips all files that exist, even though your linked question indicates that you need to update changed files.



          Your code checks that file is non-empty, but rsync is already doing this for you with --min-size=1.



          More generally, before you code up file-sync logic, it's best to read the rsync man page and see if your problem is already solved. Syncing files is a task full of corner cases and gotchas; life is too short for you to find them all. Just let rsync take care of it, whenever possible.



          The code below will update changed files while skipping unchanged files (as in your problem description). If you want to copy only new, non-existing files (as in your posted code), add --ignore-existing to the rsync options.



          import datetime
          import subprocess

          def Copy_Logs():
          Sourcedir = datetime.datetime.now().strftime("/data1/logs/%B/%b_%d_%y/")
          Destdir = "/data2/logs/"
          subprocess.call(['rsync', '-avz', '--min-size=1', '--include=*.txt', '--exclude=*', Sourcedir, Destdir ])






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 5 hours ago









          Oh My GoodnessOh My Goodness

          22614




          22614








          • 1




            $begingroup$
            This is a good answer! I'd recommend using PEP8 names though (copy_logs, source_dir, and dest_dir). It may also be prudent to note that you may be able to achieve this with a bash oneliner like rsync -avz --min-size=1 --include=*.txt --exclude=* /data/logs/$(date "+%B/%b_%d_%y/") /data2/logs/. Don't pull out Python when you don't need to!
            $endgroup$
            – Bailey Parker
            3 hours ago










          • $begingroup$
            If this isn't part of some larger Python project, you're absolutely right and there's no reason to use more than rsync and a shell. I will point out that your one-liner should quote the wildcards (yes, they'll almost never get interpolated by the shell as-is, but will it ever be baffling on the day that you have a file named --exclude=!) and doesn't need to quote the date format: rsync -avz --min-size=1 --include="*.txt" --exclude="*" /data1/logs/$(date +%B/%b_%d_%y/) /data2/logs/
            $endgroup$
            – Oh My Goodness
            2 hours ago












          • $begingroup$
            @OhMyGoodness, thanks for giving the nice and precise details, However, current code I have do not skips all the files it only skips the empty files as I test the code by running it on my data but its current not to use own method while rsync is taking care that already.
            $endgroup$
            – krock1516
            28 mins ago












          • $begingroup$
            @BaileyParker, many thanks for a suggesting a nice one liner i'll keep that handy though.
            $endgroup$
            – krock1516
            26 mins ago










          • $begingroup$
            @krock1516 I don't understand how this doesn't skip existing files. What does if not os.path.exists(Destdir + os.path.basename(filename)): do? It tests that the file does not exist...
            $endgroup$
            – Oh My Goodness
            13 mins ago














          • 1




            $begingroup$
            This is a good answer! I'd recommend using PEP8 names though (copy_logs, source_dir, and dest_dir). It may also be prudent to note that you may be able to achieve this with a bash oneliner like rsync -avz --min-size=1 --include=*.txt --exclude=* /data/logs/$(date "+%B/%b_%d_%y/") /data2/logs/. Don't pull out Python when you don't need to!
            $endgroup$
            – Bailey Parker
            3 hours ago










          • $begingroup$
            If this isn't part of some larger Python project, you're absolutely right and there's no reason to use more than rsync and a shell. I will point out that your one-liner should quote the wildcards (yes, they'll almost never get interpolated by the shell as-is, but will it ever be baffling on the day that you have a file named --exclude=!) and doesn't need to quote the date format: rsync -avz --min-size=1 --include="*.txt" --exclude="*" /data1/logs/$(date +%B/%b_%d_%y/) /data2/logs/
            $endgroup$
            – Oh My Goodness
            2 hours ago












          • $begingroup$
            @OhMyGoodness, thanks for giving the nice and precise details, However, current code I have do not skips all the files it only skips the empty files as I test the code by running it on my data but its current not to use own method while rsync is taking care that already.
            $endgroup$
            – krock1516
            28 mins ago












          • $begingroup$
            @BaileyParker, many thanks for a suggesting a nice one liner i'll keep that handy though.
            $endgroup$
            – krock1516
            26 mins ago










          • $begingroup$
            @krock1516 I don't understand how this doesn't skip existing files. What does if not os.path.exists(Destdir + os.path.basename(filename)): do? It tests that the file does not exist...
            $endgroup$
            – Oh My Goodness
            13 mins ago








          1




          1




          $begingroup$
          This is a good answer! I'd recommend using PEP8 names though (copy_logs, source_dir, and dest_dir). It may also be prudent to note that you may be able to achieve this with a bash oneliner like rsync -avz --min-size=1 --include=*.txt --exclude=* /data/logs/$(date "+%B/%b_%d_%y/") /data2/logs/. Don't pull out Python when you don't need to!
          $endgroup$
          – Bailey Parker
          3 hours ago




          $begingroup$
          This is a good answer! I'd recommend using PEP8 names though (copy_logs, source_dir, and dest_dir). It may also be prudent to note that you may be able to achieve this with a bash oneliner like rsync -avz --min-size=1 --include=*.txt --exclude=* /data/logs/$(date "+%B/%b_%d_%y/") /data2/logs/. Don't pull out Python when you don't need to!
          $endgroup$
          – Bailey Parker
          3 hours ago












          $begingroup$
          If this isn't part of some larger Python project, you're absolutely right and there's no reason to use more than rsync and a shell. I will point out that your one-liner should quote the wildcards (yes, they'll almost never get interpolated by the shell as-is, but will it ever be baffling on the day that you have a file named --exclude=!) and doesn't need to quote the date format: rsync -avz --min-size=1 --include="*.txt" --exclude="*" /data1/logs/$(date +%B/%b_%d_%y/) /data2/logs/
          $endgroup$
          – Oh My Goodness
          2 hours ago






          $begingroup$
          If this isn't part of some larger Python project, you're absolutely right and there's no reason to use more than rsync and a shell. I will point out that your one-liner should quote the wildcards (yes, they'll almost never get interpolated by the shell as-is, but will it ever be baffling on the day that you have a file named --exclude=!) and doesn't need to quote the date format: rsync -avz --min-size=1 --include="*.txt" --exclude="*" /data1/logs/$(date +%B/%b_%d_%y/) /data2/logs/
          $endgroup$
          – Oh My Goodness
          2 hours ago














          $begingroup$
          @OhMyGoodness, thanks for giving the nice and precise details, However, current code I have do not skips all the files it only skips the empty files as I test the code by running it on my data but its current not to use own method while rsync is taking care that already.
          $endgroup$
          – krock1516
          28 mins ago






          $begingroup$
          @OhMyGoodness, thanks for giving the nice and precise details, However, current code I have do not skips all the files it only skips the empty files as I test the code by running it on my data but its current not to use own method while rsync is taking care that already.
          $endgroup$
          – krock1516
          28 mins ago














          $begingroup$
          @BaileyParker, many thanks for a suggesting a nice one liner i'll keep that handy though.
          $endgroup$
          – krock1516
          26 mins ago




          $begingroup$
          @BaileyParker, many thanks for a suggesting a nice one liner i'll keep that handy though.
          $endgroup$
          – krock1516
          26 mins ago












          $begingroup$
          @krock1516 I don't understand how this doesn't skip existing files. What does if not os.path.exists(Destdir + os.path.basename(filename)): do? It tests that the file does not exist...
          $endgroup$
          – Oh My Goodness
          13 mins ago




          $begingroup$
          @krock1516 I don't understand how this doesn't skip existing files. What does if not os.path.exists(Destdir + os.path.basename(filename)): do? It tests that the file does not exist...
          $endgroup$
          – Oh My Goodness
          13 mins ago










          krock1516 is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          krock1516 is a new contributor. Be nice, and check out our Code of Conduct.













          krock1516 is a new contributor. Be nice, and check out our Code of Conduct.












          krock1516 is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Code Review Stack Exchange!


          • 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.


          Use MathJax to format equations. MathJax reference.


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




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f212074%2fcopying-files-locally-with-rsync-and-subprocess%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Сан-Квентин

          Алькесар

          Josef Freinademetz