Posted by: Sourav | August 12, 2017

Find a file from user choice and copy that file to another directory and make it hidden using python,python teacher sourav,kolkata 09748184075


import os
import shutil
from shutil import copyfile

choice=’2′
##mylist=[]
##for elem in os.listdir(‘/home/sourav/Desktop/folder1’):
## if ‘jpg’ in elem:
## mylist.append(elem[:len(elem)-4])
## elif ‘png’ in elem:
## mylist.append(elem[:len(elem)-4])
## else:
## pass
##
##
##print mylist
for elem in os.listdir(‘/home/sourav/Desktop/folder1’):
if ‘jpg’ in elem or ‘png’ in elem:
## print choice, elem[:len(elem)-4]
if choice==elem[:len(elem)-4]:

copyfile(‘/home/sourav/Desktop/folder1/’ + elem, ‘/home/sourav/Desktop/folder2/.’+elem)

else:
pass

##mylist2=[]
##
##for pic in mylist:
##
## #print pic[len(pic)-4:len(pic)]
##
## mylist2.append(pic[:len(pic)-4])
##print mylist2

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: