[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Help please with code to find and move files.

inFocus

12/31/2007 2:04:00 AM

Hello,

I am new to python and wanted to write something for myself where
after inputing two words it would search entire drive and when finding
both names in files name would either copy or move thoe files to a
specified directory.

But couple of attempts did not work as desired this is one of them.
Could someone help fix it or maybe give a better example.

Thank you very much.


import os, os.path, shutil

path = r"c:\\"
dest_file = 'C:\\files'
name_search = raw_input('Please enter name searchs : ').split()
dup = []


for root, dirs, files in os.walk(path):
for name in files:
file_name = os.path.join(root, name)
if (name_search[0] in file_name) and (name_search[1]
in file_name):
#if os.path.join(root, name) in dest_file:
if file_name in dup:
break
else:
print "copied %s to %s" % (name,
dest_file)
shutil.copy(os.path.join(root, name),
dest_file)
dup.append(file_name)
11 Answers

infixum

12/31/2007 2:43:00 AM

0


> path = r"c:\\"

I don't know if this is the whole problem, but this line should read
r'c:\' (one backslash).

inFocus

12/31/2007 2:51:00 AM

0

On Sun, 30 Dec 2007 18:42:50 -0800 (PST), infixum <ctrachte@gmail.com>
wrote:

>
>> path = r"c:\\"
>
>I don't know if this is the whole problem, but this line should read
>r'c:\' (one backslash).


after changing i got this

path = r"c:\"
^
SyntaxError: EOL while scanning single-quoted string

infixum

12/31/2007 2:56:00 AM

0


>
> after changing i got this
>
>     path = r"c:\"
>                 ^
> SyntaxError: EOL while scanning single-quoted string

Sorry about that. You can't end with a backslash - my bad. I just
tried this in the interpreter and 'c:' works.

John Machin

12/31/2007 3:30:00 AM

0

On Dec 31, 1:04 pm, inFo...@sl.com wrote:
> Hello,
>
> I am new to python and wanted to write something for myself where
> after inputing two words it would search entire drive and when finding
> both names in files name would either copy or move thoe files to a
> specified directory.
>
> But couple of attempts did not work as desired this is one of them.

Care to provide some more details than "did not work as desired"? Do
you think the problem is in the finding or in the copying? I've given
some comments below, but you really need to think through what "as
desired" means ...

Suppose your search words are "foo" and "bar", that C:\files is an
empty folder, and the following 3 files exist:
C:\a\foobar.txt
C:\b\foobar.txt
C:\b\barfoo.txt

What do you want to happen the first time you run the script? ... if
you run it a second time? If it's your intention not to make a copy of
C:\b\foobar.txt (because its "basename" is the same as that of C:\a
\foobar.txt), consider the desirability of warning yourself when this
situation happens.

> Could someone help fix it or maybe give a better example.
>
>  Thank you very much.
>
> import os, os.path, shutil
>
> path = r"c:\\"

Leave out the "r"; you are getting TWO backslashes:

>>> path = r"c:\\"
>>> len(path)
4
>>>>>> import os
>>> wkr = os.walk('rd:\\')
>>> wkr.next()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StopIteration
# Nothing inside your for statement would be executed
>>> wkr = os.walk('d:\\')
>>> wkr.next()
('d:\\', a list of folders, a list of files)


> dest_file = 'C:\\files'

Presumably that would be better named dest_dir ...

> name_search = raw_input('Please enter name searchs : ').split()
> dup = []

In the (unlikely) event that an in-memory structure with no knowledge
of what happened on previous runs will do what you really want to do,
then consider a set instead of a list.

>
> for root, dirs, files in os.walk(path):
>     for name in files:
>                 file_name = os.path.join(root, name)
>                 if (name_search[0] in file_name) and (name_search[1]
> in file_name):
>                         #if os.path.join(root, name) in dest_file:
>                         if file_name in dup:

What do you really intend to do here? dup contains the FULL PATH of
each file that you have found; if you come across another instance of
one of those, either os.walk is horribly broken or your filesystem has
a loop in its directory structure.

If you really mean "am I about to try to copy over the top of an
existing file", attack the problem head-on: make the full path of the
file you are about to try to create, and use os.path.exists on it.

>                                 break

Why break?

You also want to avoid trying to copy files in the backup
("dest_file") directory, perhaps including ones that you have just
copied there. Try a simple test
if root == dest_file:
continue
very early in your outer loop. It's probably a good idea to wrap
os.path.abspath() around root and destfile.

>                         else:
>                                 print "copied %s to %s" % (name,
> dest_file)
>                                 shutil.copy(os.path.join(root, name),
> dest_file)

You may prefer the results of copy2 to those of copy.

>                                 dup.append(file_name)

HTH,
John

inFocus

12/31/2007 3:44:00 AM

0

On Sun, 30 Dec 2007 19:29:38 -0800 (PST), John Machin
<sjmachin@lexicon.net> wrote:

>On Dec 31, 1:04 pm, inFo...@sl.com wrote:
>> Hello,
>>
>> I am new to python and wanted to write something for myself where
>> after inputing two words it would search entire drive and when finding
>> both names in files name would either copy or move thoe files to a
>> specified directory.
>>
>> But couple of attempts did not work as desired this is one of them.
>
>Care to provide some more details than "did not work as desired"? Do
>you think the problem is in the finding or in the copying? I've given
>some comments below, but you really need to think through what "as
>desired" means ...
>
>Suppose your search words are "foo" and "bar", that C:\files is an
>empty folder, and the following 3 files exist:
>C:\a\foobar.txt
>C:\b\foobar.txt
>C:\b\barfoo.txt
>
>What do you want to happen the first time you run the script? ... if
>you run it a second time? If it's your intention not to make a copy of
>C:\b\foobar.txt (because its "basename" is the same as that of C:\a
>\foobar.txt), consider the desirability of warning yourself when this
>situation happens.
>
>> Could someone help fix it or maybe give a better example.
>>
>>  Thank you very much.
>>
>> import os, os.path, shutil
>>
>> path = r"c:\\"
>
>Leave out the "r"; you are getting TWO backslashes:
>
>>>> path = r"c:\\"
>>>> len(path)
>4
>>>>>>> import os
>>>> wkr = os.walk('rd:\\')
>>>> wkr.next()
>Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
>StopIteration
># Nothing inside your for statement would be executed
>>>> wkr = os.walk('d:\\')
>>>> wkr.next()
>('d:\\', a list of folders, a list of files)
>
>
>> dest_file = 'C:\\files'
>
>Presumably that would be better named dest_dir ...
>
>> name_search = raw_input('Please enter name searchs : ').split()
>> dup = []
>
>In the (unlikely) event that an in-memory structure with no knowledge
>of what happened on previous runs will do what you really want to do,
>then consider a set instead of a list.
>
>>
>> for root, dirs, files in os.walk(path):
>>     for name in files:
>>                 file_name = os.path.join(root, name)
>>                 if (name_search[0] in file_name) and (name_search[1]
>> in file_name):
>>                         #if os.path.join(root, name) in dest_file:
>>                         if file_name in dup:
>
>What do you really intend to do here? dup contains the FULL PATH of
>each file that you have found; if you come across another instance of
>one of those, either os.walk is horribly broken or your filesystem has
>a loop in its directory structure.
>
>If you really mean "am I about to try to copy over the top of an
>existing file", attack the problem head-on: make the full path of the
>file you are about to try to create, and use os.path.exists on it.
>
>>                                 break
>
>Why break?
>
>You also want to avoid trying to copy files in the backup
>("dest_file") directory, perhaps including ones that you have just
>copied there. Try a simple test
> if root == dest_file:
> continue
>very early in your outer loop. It's probably a good idea to wrap
>os.path.abspath() around root and destfile.
>
>>                         else:
>>                                 print "copied %s to %s" % (name,
>> dest_file)
>>                                 shutil.copy(os.path.join(root, name),
>> dest_file)
>
>You may prefer the results of copy2 to those of copy.
>
>>                                 dup.append(file_name)
>
>HTH,
>John

John,

What I was trying to do is find files that are scattered all over my
hard drive that contain similar two words in them like bar and foo
and move them to one desired location removing from where they were
originally. The did not work as desired were attempts when it would
attempt to read and write to the same location.so i would get an error
saying that source and destination were the same.

John Machin

12/31/2007 4:49:00 AM

0

On Dec 31, 2:44 pm, inFo...@sl.com wrote:
> On Sun, 30 Dec 2007 19:29:38 -0800 (PST), John Machin
>
>
>
>
>
> <sjmac...@lexicon.net> wrote:
> >On Dec 31, 1:04 pm, inFo...@sl.com wrote:
> >> Hello,
>
> >> I am new to python and wanted to write something for myself where
> >> after inputing two words it would search entire drive and when finding
> >> both names in files name would either copy or move thoe files to a
> >> specified directory.
>
> >> But couple of attempts did not work as desired this is one of them.
>
> >Care to provide some more details than "did not work as desired"? Do
> >you think the problem is in the finding or in the copying? I've given
> >some comments below, but you really need to think through what "as
> >desired" means ...
>
> >Suppose your search words are "foo" and "bar", that C:\files is an
> >empty folder, and the following 3 files exist:
> >C:\a\foobar.txt
> >C:\b\foobar.txt
> >C:\b\barfoo.txt
>
> >What do you want to happen the first time you run the script? ... if
> >you run it a second time? If it's your intention not to make a copy of
> >C:\b\foobar.txt (because its "basename" is the same as that of C:\a
> >\foobar.txt), consider the desirability of warning yourself when this
> >situation happens.
>
> >> Could someone help fix it or maybe give a better example.
>
> >>  Thank you very much.
>
> >> import os, os.path, shutil
>
> >> path = r"c:\\"
>
> >Leave out the "r"; you are getting TWO backslashes:
>
> >>>> path = r"c:\\"
> >>>> len(path)
> >4
> >>>>>>> import os
> >>>> wkr = os.walk('rd:\\')
> >>>> wkr.next()
> >Traceback (most recent call last):
> >  File "<stdin>", line 1, in <module>
> >StopIteration
> ># Nothing inside your for statement would be executed
> >>>> wkr = os.walk('d:\\')
> >>>> wkr.next()
> >('d:\\', a list of folders, a list of files)
>
> >> dest_file = 'C:\\files'
>
> >Presumably that would be better named dest_dir ...
>
> >> name_search = raw_input('Please enter name searchs : ').split()
> >> dup = []
>
> >In the (unlikely) event that an in-memory structure with no knowledge
> >of what happened on previous runs will do what you really want to do,
> >then consider a set instead of a list.
>
> >> for root, dirs, files in os.walk(path):
> >>     for name in files:
> >>                 file_name = os.path.join(root, name)
> >>                 if (name_search[0] in file_name) and (name_search[1]
> >> in file_name):
> >>                         #if os.path.join(root, name) in dest_file:
> >>                         if file_name in dup:
>
> >What do you really intend to do here? dup contains the FULL PATH of
> >each file that you have found; if you come across another instance of
> >one of those, either os.walk is horribly broken or your filesystem has
> >a loop in its directory structure.
>
> >If you really mean "am I about to try to copy over the top of an
> >existing file", attack the problem head-on: make the full path of the
> >file you are about to try to create, and use os.path.exists on it.
>
> >>                                 break
>
> >Why break?
>
> >You also want to avoid trying to copy files in the backup
> >("dest_file") directory, perhaps including ones that you have just
> >copied there. Try a simple test
> >    if root == dest_file:
> >        continue
> >very early in your outer loop. It's probably a good idea to wrap
> >os.path.abspath() around root and destfile.
>
> >>                         else:
> >>                                 print "copied %s to %s" % (name,
> >> dest_file)
> >>                                 shutil.copy(os.path.join(root, name),
> >> dest_file)
>
> >You may prefer the results of copy2 to those of copy.
>
> >>                                 dup.append(file_name)
>
> >HTH,
> >John
>
> John,
>
> What I was trying to do is find files that are scattered all over my
> hard drive that contain similar two words in them like bar and foo
> and move them to one desired location removing from where they were
> originally.  The did not work as desired were attempts when it would
> attempt to read and write to the same location.so i would get an error
> saying that source and destination were  the same.- Hide quoted text -
>
> - Show quoted text -

The script that you showed would not have found any files to move/
copy, as "infixum" and I have pointed out.

Imagine that you were trying to help someone with a Python problem ...
would you not like them to tell you (with some precision) what they
were trying to do, what was the script that they actually ran, what
the precise result (including stack trace and error message if any)
was? Or do you like playing guessing games?

inFocus

12/31/2007 4:58:00 AM

0

On Sun, 30 Dec 2007 20:49:29 -0800 (PST), John Machin
<sjmachin@lexicon.net> wrote:

>On Dec 31, 2:44 pm, inFo...@sl.com wrote:
>> On Sun, 30 Dec 2007 19:29:38 -0800 (PST), John Machin
>>
>>
>>
>>
>>
>> <sjmac...@lexicon.net> wrote:
>> >On Dec 31, 1:04 pm, inFo...@sl.com wrote:
>> >> Hello,
>>
>> >> I am new to python and wanted to write something for myself where
>> >> after inputing two words it would search entire drive and when finding
>> >> both names in files name would either copy or move thoe files to a
>> >> specified directory.
>>
>> >> But couple of attempts did not work as desired this is one of them.
>>
>> >Care to provide some more details than "did not work as desired"? Do
>> >you think the problem is in the finding or in the copying? I've given
>> >some comments below, but you really need to think through what "as
>> >desired" means ...
>>
>> >Suppose your search words are "foo" and "bar", that C:\files is an
>> >empty folder, and the following 3 files exist:
>> >C:\a\foobar.txt
>> >C:\b\foobar.txt
>> >C:\b\barfoo.txt
>>
>> >What do you want to happen the first time you run the script? ... if
>> >you run it a second time? If it's your intention not to make a copy of
>> >C:\b\foobar.txt (because its "basename" is the same as that of C:\a
>> >\foobar.txt), consider the desirability of warning yourself when this
>> >situation happens.
>>
>> >> Could someone help fix it or maybe give a better example.
>>
>> >>  Thank you very much.
>>
>> >> import os, os.path, shutil
>>
>> >> path = r"c:\\"
>>
>> >Leave out the "r"; you are getting TWO backslashes:
>>
>> >>>> path = r"c:\\"
>> >>>> len(path)
>> >4
>> >>>>>>> import os
>> >>>> wkr = os.walk('rd:\\')
>> >>>> wkr.next()
>> >Traceback (most recent call last):
>> >  File "<stdin>", line 1, in <module>
>> >StopIteration
>> ># Nothing inside your for statement would be executed
>> >>>> wkr = os.walk('d:\\')
>> >>>> wkr.next()
>> >('d:\\', a list of folders, a list of files)
>>
>> >> dest_file = 'C:\\files'
>>
>> >Presumably that would be better named dest_dir ...
>>
>> >> name_search = raw_input('Please enter name searchs : ').split()
>> >> dup = []
>>
>> >In the (unlikely) event that an in-memory structure with no knowledge
>> >of what happened on previous runs will do what you really want to do,
>> >then consider a set instead of a list.
>>
>> >> for root, dirs, files in os.walk(path):
>> >>     for name in files:
>> >>                 file_name = os.path.join(root, name)
>> >>                 if (name_search[0] in file_name) and (name_search[1]
>> >> in file_name):
>> >>                         #if os.path.join(root, name) in dest_file:
>> >>                         if file_name in dup:
>>
>> >What do you really intend to do here? dup contains the FULL PATH of
>> >each file that you have found; if you come across another instance of
>> >one of those, either os.walk is horribly broken or your filesystem has
>> >a loop in its directory structure.
>>
>> >If you really mean "am I about to try to copy over the top of an
>> >existing file", attack the problem head-on: make the full path of the
>> >file you are about to try to create, and use os.path.exists on it.
>>
>> >>                                 break
>>
>> >Why break?
>>
>> >You also want to avoid trying to copy files in the backup
>> >("dest_file") directory, perhaps including ones that you have just
>> >copied there. Try a simple test
>> >    if root == dest_file:
>> >        continue
>> >very early in your outer loop. It's probably a good idea to wrap
>> >os.path.abspath() around root and destfile.
>>
>> >>                         else:
>> >>                                 print "copied %s to %s" % (name,
>> >> dest_file)
>> >>                                 shutil.copy(os.path.join(root, name),
>> >> dest_file)
>>
>> >You may prefer the results of copy2 to those of copy.
>>
>> >>                                 dup.append(file_name)
>>
>> >HTH,
>> >John
>>
>> John,
>>
>> What I was trying to do is find files that are scattered all over my
>> hard drive that contain similar two words in them like bar and foo
>> and move them to one desired location removing from where they were
>> originally.  The did not work as desired were attempts when it would
>> attempt to read and write to the same location.so i would get an error
>> saying that source and destination were  the same.- Hide quoted text -
>>
>> - Show quoted text -
>
>The script that you showed would not have found any files to move/
>copy, as "infixum" and I have pointed out.
>
>Imagine that you were trying to help someone with a Python problem ...
>would you not like them to tell you (with some precision) what they
>were trying to do, what was the script that they actually ran, what
>the precise result (including stack trace and error message if any)
>was? Or do you like playing guessing games?


I am sorry i thought I did say what I was tryng to do.

Dennis Lee Bieber

12/31/2007 6:53:00 AM

0

On Sun, 30 Dec 2007 23:58:17 -0500, inFocus@sl.com declaimed the
following in comp.lang.python:


> I am sorry i thought I did say what I was tryng to do.

The only thing I picked up from the thread is that you attempted to
move any file, whose name contained -- in any order/position -- two
specific substrings, from some specified source directory tree to a
single specified directory.

Among the unknowns: what happens if two source directories have
files with identical names! Does the second overwrite the first? Does
the second NOT get moved? Should the second have the name modified with
a suffix count?

a/something.wht -> dest/something.wht
b/something.wht -> ?????
1) replace the first something.wht
(thereby losing a/something.wht)
2) don't move -- leaving
b/something.wht unmoved
3) rename as
dest/something1.wht

Neither do I have any idea of what type of problem you really
encountered (you'll have to forgive me, but I do not intend to try
running your script, on my system, given that I do not know what the
effects, in the end, are to be).

The closest to what you seem to ask, that I've created in the past,
is a task to identify potential duplicate files (I have a large number
of downloaded images). Note the date -- I think it predated os.walk()

-=-=-=-=-=-=-
#
# DupCheck.py -- Scans a directory and all subdirectories
# for duplicate file names, reporting conflicts
# March 22 1998 dl bieber <wulfraed@netcom.com>
#

import os
import sys
import string
from stat import *

Files = {}

def Scan_Dir(cd):
global Files, logfile

cur_files = os.listdir(cd)
cur_files.sort()
for f in cur_files:
fib = os.stat("%s\\%s" % (cd, f))
if S_ISDIR(fib[ST_MODE]):
Scan_Dir("%s\\%s" % (cd, f))
elif S_ISREG(fib[ST_MODE]):
if Files.has_key(string.lower(f)):
(aSize, aDir) = Files[string.lower(f)]
if fib[ST_SIZE] == aSize:
logfile.write(
"***** Possible Duplicate File: %s\n" % (f))
logfile.write(
" %s\t%s\n" % (fib[ST_SIZE], cd))
logfile.write(
" %s\t%s\n\n" % (Files[string.lower(f)]))
else:
Files[string.lower(f)] = (fib[ST_SIZE], cd)
else:
logfile.write(
"***** SKIPPED Not File or Dir: %s\n\n" % (f))


if __name__ == "__main__":
Cur_Dir = raw_input("Root Directory -> ")
Log_To = raw_input("Log File -> ")

if Log_To:
logfile = open(Log_To, "w")
else:
logfile = sys.stdout

Scan_Dir(Cur_Dir)

if Log_To:
logfile.close()
-=-=-=-=-=-
--
Wulfraed Dennis Lee Bieber KD6MOG
wlfraed@ix.netcom.com wulfraed@bestiaria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: web-asst@bestiaria.com)
HTTP://www.bestiaria.com/

inFocus

12/31/2007 7:10:00 AM

0

On Sun, 30 Dec 2007 22:52:32 -0800, Dennis Lee Bieber
<wlfraed@ix.netcom.com> wrote:

>On Sun, 30 Dec 2007 23:58:17 -0500, inFocus@sl.com declaimed the
>following in comp.lang.python:
>
>
>> I am sorry i thought I did say what I was tryng to do.
>
> The only thing I picked up from the thread is that you attempted to
>move any file, whose name contained -- in any order/position -- two
>specific substrings, from some specified source directory tree to a
>single specified directory.
>
> Among the unknowns: what happens if two source directories have
>files with identical names! Does the second overwrite the first? Does
>the second NOT get moved? Should the second have the name modified with
>a suffix count?
>
> a/something.wht -> dest/something.wht
> b/something.wht -> ?????
> 1) replace the first something.wht
> (thereby losing a/something.wht)
> 2) don't move -- leaving
> b/something.wht unmoved
> 3) rename as
> dest/something1.wht
>
> Neither do I have any idea of what type of problem you really
>encountered (you'll have to forgive me, but I do not intend to try
>running your script, on my system, given that I do not know what the
>effects, in the end, are to be).
>
> The closest to what you seem to ask, that I've created in the past,
>is a task to identify potential duplicate files (I have a large number
>of downloaded images). Note the date -- I think it predated os.walk()
>
>-=-=-=-=-=-=-
>#
># DupCheck.py -- Scans a directory and all subdirectories
># for duplicate file names, reporting conflicts
># March 22 1998 dl bieber <wulfraed@netcom.com>
>#
>
>import os
>import sys
>import string
>from stat import *
>
>Files = {}
>
>def Scan_Dir(cd):
> global Files, logfile
>
> cur_files = os.listdir(cd)
> cur_files.sort()
> for f in cur_files:
> fib = os.stat("%s\\%s" % (cd, f))
> if S_ISDIR(fib[ST_MODE]):
> Scan_Dir("%s\\%s" % (cd, f))
> elif S_ISREG(fib[ST_MODE]):
> if Files.has_key(string.lower(f)):
> (aSize, aDir) = Files[string.lower(f)]
> if fib[ST_SIZE] == aSize:
> logfile.write(
> "***** Possible Duplicate File: %s\n" % (f))
> logfile.write(
> " %s\t%s\n" % (fib[ST_SIZE], cd))
> logfile.write(
> " %s\t%s\n\n" % (Files[string.lower(f)]))
> else:
> Files[string.lower(f)] = (fib[ST_SIZE], cd)
> else:
> logfile.write(
> "***** SKIPPED Not File or Dir: %s\n\n" % (f))
>
>
>if __name__ == "__main__":
> Cur_Dir = raw_input("Root Directory -> ")
> Log_To = raw_input("Log File -> ")
>
> if Log_To:
> logfile = open(Log_To, "w")
> else:
> logfile = sys.stdout
>
> Scan_Dir(Cur_Dir)
>
> if Log_To:
> logfile.close()
>-=-=-=-=-=-

I am sorry if I was not clear in what I was trying to achieve. All I
wanted was simple way to achieve what windows does when you use search
for Files or Folders, and all the files that mach two words like foo
and bar in the file name to be moved or copied to a specified folder,
duplicates should not be copied just skipped.

Dennis Lee Bieber

12/31/2007 7:56:00 AM

0

On Mon, 31 Dec 2007 02:09:37 -0500, inFocus@sl.com declaimed the
following in comp.lang.python:


> I am sorry if I was not clear in what I was trying to achieve. All I
> wanted was simple way to achieve what windows does when you use search
> for Files or Folders, and all the files that mach two words like foo
> and bar in the file name to be moved or copied to a specified folder,
> duplicates should not be copied just skipped.

Well... /my/ "search files or folders" only matches names that meet
a wildcard expression, not one where there are two substrings that occur
somewhere in the name.

eg: *foo*bar* will match
afooandbar.txt
but will not match
abarbeforefoo.txt

If it matching similar to "search", check the documentation on glob
and/or fnmatch which take similar patterns.

-=-=-=-=-=-=- **** UNTESTED
import os
import os.path
import sys
from stat import *
from fnmatch import fnmatch
import os.path

def Scan_Dir(cd, dest, pat):
cur_files = os.listdir(cd)
cur_files.sort()
for f in cur_files:
fp = os.path.join(cd, f)
fib = os.stat(fp)
if S_ISDIR(fib[ST_MODE]):
Scan_Dir(fp)
elif S_ISREG(fib[ST_MODE]):
if fnmatch(f, pat):
if not os.path.exists(os.path.join(dest, f)):
#put in move logic here
#os.rename(fp, os.path.join(dest, f))
print "moving %s to %s" % (fp, dest)
else:
print "skipping duplicate name %s" % fp
else:
print "***** SKIPPED Not File or Dir: %s\n\n" % (f))


if __name__ == "__main__":
Cur_Dir = raw_input("Root Directory -> ")
Dest_Dir = raw_input("Destination Directory -> ")
Pattern = raw_input("Filename pattern -> ")

Scan_Dir(Cur_Dir, Dest_Dir, Pattern)
-=-=-=-=-=-=-

Could use modernization with walk(); if walk() returns a list of
files and a list of directories, one could use fnmatch.filter(filelist,
pattern) to reduce the list of files, then perform an attempted move on
each one in the list... and THEN recurse downward in the tree.
--
Wulfraed Dennis Lee Bieber KD6MOG
wlfraed@ix.netcom.com wulfraed@bestiaria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: web-asst@bestiaria.com)
HTTP://www.bestiaria.com/