<br><br><div class="gmail_quote">On Tue, Nov 9, 2010 at 7:15 AM, Joseph John <span dir="ltr">&lt;<a href="mailto:jjk.saji@gmail.com">jjk.saji@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi All<br>
   I am trying our &quot;Python&quot; .<br>
   My aim is to copy a file to a location and later removing the<br>
file.I had written a small script which works.It works only if I<br>
specify the source file name. I would like to make it work in a<br>
scenario in which I do not know the name of the source file(the source<br>
directory will have only one file at any time)<br>
<br>
I am posting the script which I have done,How to modify the script to<br>
copy the source file even if I do not know the name of the file<br>
my script is below<br>
<br>
###############################################<br>
#!/usr/bin/python<br>
<br>
# This script aims to copy file from one directoy to anothe and later<br>
removing the files<br>
# This script works when I know the source file name, I want to this<br>
script to function even if I do not know the name of<br>
# the file in &quot;/home/joseph/Projects/Training/Python/example/One/&quot;<br>
<br>
import shutil<br>
# &quot;FromOne&quot; is a file in /home/joseph/Projects/Training/Python/example/One/<br>
src = &quot;/home/joseph/Projects/Training/Python/example/One/FromOne&quot;<br>
#<br>
dst2 = &quot;/home/joseph/Projects/Training/Python/example/Two/&quot;<br>
dst3 = &quot;/home/joseph/Projects/Training/Python/example/Three/&quot;<br>
#<br>
<br>
#<br>
#shutil.move(src, dst)<br>
shutil.copy(src,dst2)<br>
shutil.move(src,dst3)<br>
<br>
######################################<br>
<font color="#888888"><br>
<br>
<br>
<br>
--<br>
Thanks<br>
Joseph John<br>
<a href="http://www.oss101.com/" target="_blank">http://www.oss101.com/</a></font></blockquote><div><br><dl class="function"><dt id="os.listdir">
<tt class="descclassname">os.</tt><tt class="descname">listdir</tt><big>(</big><em>path</em><big>)</big><a class="headerlink" href="http://docs.python.org/library/os.html#os.listdir" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list containing the names of the entries in the directory given by
<em>path</em>.  The list is in arbitrary order.  It does not include the special
entries <tt class="docutils literal"><span class="pre">&#39;.&#39;</span></tt> and <tt class="docutils literal"><span class="pre">&#39;..&#39;</span></tt> even if they are present in the
directory.</p>
<p><br></p></dd></dl> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><font color="#888888"><br>
_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Joel Goldstick<br><br>