Firefox 16, a treat for developers http://t.co/cnd27CzT
Copy files or directories in Python programming
This script is presented by Patrick Lapre. a member of Unixmen community

#/usr/bin/env python
Small intro: Copying files with a specific pattern from its origin to its final destination ;-)
# import the following modules
# re is needed for patterns
import re
# os.path to define file manipulation
import os.path
# dircache is used for listing directories
import dircache
# shutil is used for copying files
import shutil
# Defined some global variables to be used later on
From_Path = “”"/Users/carllapre/test/from/”"”
To_Path = “”"/Users/carllapre/test/to/”"”
a = dircache.listdir( From_Path )
# make a copy of the array to manipulate later on
a = a[:]
# print statement just for debugging
print a
# create string value to be used later on
b = ” “.join( a )
print b
# look it is a pattern ;-)
pattern = re.compile( ‘rbs.*’ )
print pattern
# This is the actual patternmatch
c = re.findall( pattern, b )
print c
# Stick it all together again
e = “”.join( c )
# and now for the split
splitter = re.compile( ‘ ‘ )
d = splitter.split( e )
print d
# Ok this is a loop to check if the file
# already exists in the destination directory
# If not then copy the file to its destination
for i in d:
print i
File_Exist = To_Path + i
# check if the file already exists in its destionation folder
x = ( os.path.isfile( File_Exist ) )
# using a reserved word to check the condition
if x == False:
print “”"Copying file to “”" + To_Path
Source = From_Path + i
Destination = To_Path + i
# actual copy action
shutil.copy2( Source, Destination )
else:
print “”"File already exists at location “”" + To_Path
print “”"n Doing Nothing!!!”"”
Like us on Facebook
This week Top Posts 
Top Things to do After Installing Ubuntu 13.04 ‘Raring Ringtail’ : Ubuntu 13.04 Raring Ringtail final is almost out. The final release it scheduled for release on Apri...0 comment(s) |
Install lamp with 1 command in Ubuntu 12.10, 13.04 Raring Ringtail & LinuxMint13 : Updated: 10/09/2012 :LAMP (Linux, Apache, MySQL and PHP) is an open source Web development platform ...0 comment(s) |
Howto: Upgrade to Ubuntu 13.04 Raring Ringtail from 12.04, 12,10 | Desktop & Server : Updated 05-04-2013: Ubuntu 13.04 Raring Ringtail will be released Soon, If you have ubuntu 12,10, 12...0 comment(s) |
Steganography- Hide Your Files Inside An Image in Linux : Nowadays, our personal computer is not only a work tool, it is also our private space where we sto...1 comment(s) |
Scan Your Home Network With Nmap : Who should read this article? Everyone who is interested in computer security and computer networkin...0 comment(s) |
How to use Remote Desktop in Ubuntu : Sometimes, we need to access our computer from other locations when we’re not at home and such. This...0 comment(s) |
Recent Posts
- Secure File from Removal in Linux and Unix
- How to Install Nginx on FreeBSD 9.x
- Create a Launcher in Ubuntu Using Bash
- Scan Your Home Network With Nmap
- Steganography- Hide Your Files Inside An Image in Linux
- Unix/Linux File Recognition. Did You Know?
- Migrate from MySQL to MariaDB in FreeBSD
- Connect Your Android Galaxy Tablet to Ubuntu via USB
- ElementaryOS Beta 1 and 2 Comparison and Review
- Introduction to the Linux Command Line
Recent Comments



















Pat L
| #
I tried it and it works with a regular zip file, but if you password-protect the .zip file it does NOT work.
SK
| #
Yes we can. What kind of help you need? We are doing outsourcing and technical support for Linux and Open source worldwide. To know more about the details visit here.
ClintB
| #
After install as above, run shell script /opt/Citrix/ICAClient/wfica.sh manually and note lib errors still occur. I had the x64 motif loaded but had to manually install the x86 too. Got that from http://rpmfind.net/linux/rpm2html/search.php?query=libXm.so.4 Even after that, I still had to do a “yum install alsa-lib.i686 alsa-lib.x86_64″ to resolve any additional libasound.so.2 errors. Once those two lib issues were resolved, Citix Web Interface launched apps fine by telling browser to open launch.ica using /opt/Citrix/ICAClient/wfica.sh. Good luck Ernesto!
AD
| #
I need some Help on Linux,can you guide me ?
Edson Carlos
| #
In debian no found. I need link download install in linux debian