<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Timestamp a Zipfile File Name? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/timestamp-a-zipfile-file-name/m-p/489644#M38292</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Matthew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT: You answered my question, and that worked to name it correctly, but I still have a problem. I wasn't very clear but I actually want a script to put the date on existing zipfiles, this one being one of them in a folder full of them. I'm not sure if the write method is even what I should be doing. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Feb 2018 21:38:58 GMT</pubDate>
    <dc:creator>JaredPilbeam2</dc:creator>
    <dc:date>2018-02-07T21:38:58Z</dc:date>
    <item>
      <title>Timestamp a Zipfile File Name?</title>
      <link>https://community.esri.com/t5/python-questions/timestamp-a-zipfile-file-name/m-p/489642#M38290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using PythonWin 2.7.10, I would like to append a date to a bunch of zipfiles in a folder. I've been using the time module which prints the current month, day and year. But, I'm not sure how to append this date to the end of my zipfiles' file name. In this case I've been running tests on the WillCounty_PLSS.zip file, which contains a shapefile.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This script seems to work, but it creates an odd looking file with no content:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; time
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcpy &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; env

ws &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'\\gisfile\GISstaff\Jared'&lt;/SPAN&gt;

current_time &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; time&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strftime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"%m%d%Y"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
output_name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"WillCounty_PLSS.zip"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; current_time
output_file &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; open&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ws &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; output_name&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"w"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; current_time‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's how the file was named:&amp;nbsp; JaredWillCounty_PLSS.zip02072018&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT: What do I need to do to have the look like this: WillCounty_PLSS_02072018.zip?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:33:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/timestamp-a-zipfile-file-name/m-p/489642#M38290</guid>
      <dc:creator>JaredPilbeam2</dc:creator>
      <dc:date>2021-12-11T21:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp a Zipfile File Name?</title>
      <link>https://community.esri.com/t5/python-questions/timestamp-a-zipfile-file-name/m-p/489643#M38291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="" style="color: #000000; background: #f5f2f0; border: 0px; margin: 0.5em 0px; padding: 1em 1em 1em 3.8em;"&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;output_name &lt;SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;"&gt;=&lt;/SPAN&gt; &lt;SPAN class="" style="color: #669900; border: 0px; font-weight: inherit;"&gt;"WillCounty_PLSS"&lt;/SPAN&gt; &lt;SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;"&gt;+&lt;/SPAN&gt; current_time + ".zip"&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Feb 2018 21:17:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/timestamp-a-zipfile-file-name/m-p/489643#M38291</guid>
      <dc:creator>MatthewDobson</dc:creator>
      <dc:date>2018-02-07T21:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp a Zipfile File Name?</title>
      <link>https://community.esri.com/t5/python-questions/timestamp-a-zipfile-file-name/m-p/489644#M38292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Matthew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT: You answered my question, and that worked to name it correctly, but I still have a problem. I wasn't very clear but I actually want a script to put the date on existing zipfiles, this one being one of them in a folder full of them. I'm not sure if the write method is even what I should be doing. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Feb 2018 21:38:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/timestamp-a-zipfile-file-name/m-p/489644#M38292</guid>
      <dc:creator>JaredPilbeam2</dc:creator>
      <dc:date>2018-02-07T21:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp a Zipfile File Name?</title>
      <link>https://community.esri.com/t5/python-questions/timestamp-a-zipfile-file-name/m-p/489645#M38293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you wanting to do more than just rename the existing files? If it is a straight Python exercise, this link has a few different solutions.&amp;nbsp;&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/225735/batch-renaming-of-files-in-a-directory"&gt;batch-renaming-of-files-in-a-directory&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Feb 2018 22:07:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/timestamp-a-zipfile-file-name/m-p/489645#M38293</guid>
      <dc:creator>MatthewDobson</dc:creator>
      <dc:date>2018-02-07T22:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp a Zipfile File Name?</title>
      <link>https://community.esri.com/t5/python-questions/timestamp-a-zipfile-file-name/m-p/489646#M38294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; os
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; time

my_dir &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"D:\myFolder"&lt;/SPAN&gt;
current_time &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; time&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strftime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"%m%d%Y"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; dirpath&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; dnames&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; fnames &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;walk&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;my_dir&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; file &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; fnames&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; file
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; file&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;endswith&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;".zip"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ext &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;splitext&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;file&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new_file_name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"{}{}{}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;name&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; current_time&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ext&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;rename&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dirpath&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; file&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dirpath&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; new_file_name&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:33:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/timestamp-a-zipfile-file-name/m-p/489646#M38294</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-11T21:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp a Zipfile File Name?</title>
      <link>https://community.esri.com/t5/python-questions/timestamp-a-zipfile-file-name/m-p/489647#M38295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/48550"&gt;Blake Terhune&lt;/A&gt;‌'s code should let you add a date to the name of zip files in a directory.&amp;nbsp; When I use a date in a filename, I usually format it in year-month-day order as it can be useful when you sort the listing in a file folder.&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;time&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strftime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'%y%m%d'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# YYMMDD order‍&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Feb 2018 03:46:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/timestamp-a-zipfile-file-name/m-p/489647#M38295</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2018-02-08T03:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp a Zipfile File Name?</title>
      <link>https://community.esri.com/t5/python-questions/timestamp-a-zipfile-file-name/m-p/489648#M38296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jared,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There was a similar question asked last year, maybe that will help you out.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/21496"&gt;https://community.esri.com/thread/21496&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;~Shan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Feb 2018 06:34:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/timestamp-a-zipfile-file-name/m-p/489648#M38296</guid>
      <dc:creator>shan_sarkar</dc:creator>
      <dc:date>2018-02-08T06:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp a Zipfile File Name?</title>
      <link>https://community.esri.com/t5/python-questions/timestamp-a-zipfile-file-name/m-p/489649#M38297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks everybody.&lt;BR /&gt;While Matthew's renaming link was pretty much what I was looking for I decided to go with Blake's version as it was right here and works great. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Feb 2018 14:52:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/timestamp-a-zipfile-file-name/m-p/489649#M38297</guid>
      <dc:creator>JaredPilbeam2</dc:creator>
      <dc:date>2018-02-08T14:52:28Z</dc:date>
    </item>
  </channel>
</rss>

