{"id":420,"date":"2012-02-10T17:44:11","date_gmt":"2012-02-10T17:44:11","guid":{"rendered":"http:\/\/www.omniweb.com\/wordpress\/?p=420"},"modified":"2012-02-10T17:48:28","modified_gmt":"2012-02-10T17:48:28","slug":"how-to-not-overwrite-files-with-net-ftp","status":"publish","type":"post","link":"https:\/\/www.omniweb.com\/wordpress\/?p=420","title":{"rendered":"How to Not overwrite files with Net FTP"},"content":{"rendered":"<p>I&#8217;m writing a batch program to transfer files with Net::FTP and since I only want to transfer files that don&#8217;t already exist, I was looking for a setting or flag in Net:FTP to prevent overwriting. <a href=\"http:\/\/www.perlmonks.org\/?node_id=700178\">Google, perlmonks, and Claudio to the rescue<\/a><\/p>\n<p>I added this little check to my perl script:<\/p>\n<p><code> if ( $ftp-&gt;rename( $dest, $dest ) ) {<br \/>\n&nbsp; print \"File $dest already exists in $path \\n\";<br \/>\n} else {<br \/>\n&nbsp; print \"Put $local -&gt; $dest \\n\";<br \/>\n&nbsp; $ftp-&gt;put($local, $dest)<br \/>\n&nbsp; or die \"put failed \", $ftp-&gt;message;<br \/>\n}<br \/>\n$ftp-&gt;quit;<\/code><\/p>\n<p>It is indeed ingenious &#8211; thank you Claudio, whoever you are \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m writing a batch program to transfer files with Net::FTP and since I only want to transfer files that don&#8217;t already exist, I was looking for a setting or flag in Net:FTP to prevent overwriting. Google, perlmonks, and Claudio to &hellip; <a href=\"https:\/\/www.omniweb.com\/wordpress\/?p=420\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/420"}],"collection":[{"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=420"}],"version-history":[{"count":3,"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/420\/revisions"}],"predecessor-version":[{"id":423,"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/420\/revisions\/423"}],"wp:attachment":[{"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=420"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=420"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=420"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}