title: Clone folder from ftp to disk and disk to ftp
body: <p>Hi i have a ftp with a folder named fotos, i need to create a script to use as a cron that get all files from the folder but dont replace if exist and in the end put in the ftp server fotos folder all that dont exist in the server but exist in disk.</p>
  <p>I will try to explain a little better</p>
  <p>ftp -&gt; folder Fotos -&gt; several folders with subfolders with fotos and videos
  disk -&gt; drive j: -&gt; folder Fotos -&gt; several folders with subfolders with fotos and videos</p>
  <p>i need to do ftp -&gt; disk and disk -&gt; ftp without replace because i already have 50.000 files in there.</p>
  <p>this is what im working on</p>
  <pre><code>import os
  from ftplib import FTP
  
  ftp = FTP()
  server = &quot;ftp.server.com&quot;
  user = &quot;user&quot;
  passw = &quot;password&quot;
  path = &quot;Fotos&quot;
  path2 = &quot;J:\FOTOS&quot;
  
  ftp.connect(server, 21, timeout=15)
  login_response = ftp.login(user, passw)
  ftp.encoding = &quot;utf-8&quot;
  ftp.cwd(path)
  
  print(ftp.getwelcome())
  
  for ftp_file in ftp.nlst():
  
      print(&quot;checking &quot; , ftp_file)
  
      for root, dirs, files in os.walk(ftp_file):
          for name in files:
              print(name)
              if name !=&quot;Thumbs.db&quot;:
                  print(name)
  
      if ftp_file not in os.listdir(path2):
          print('Downloading file: %s' , ftp_file)
          #ftp.retrbinary('RETR '+ ftp_file ,open(ftp_file,'wb').write,rest=0)
      else:
          print(&quot;existe&quot;)
  
  
  
  print(&quot;end&quot;)
  </code></pre>
  <p>It connects to the ftp then print ('checking ', '1. Folder') and nothing more.</p>
  <p>Could this be because of the number of files in the folder?</p>
  <p>if i just add this</p>
  <pre><code>for ftp_file in ftp.nlst():
      print(&quot;checking &quot; , ftp_file)
  </code></pre>
  <p>it prints all the folders names</p>