duplicate filename query

B

buffaloes

Greetings

Can anyone suggest a solution to the following query, illustrated best
by way of example:

e.g. my hard drive has a directory folder called ANIMAL, with
subdirectory folders DOG, CAT, FISH. Say each subdirectory has a list
of files, and several filenames are duplicated within each separate
folder, so there is a file called BOB.JPG in the DOG, CAT and FISH
directory (bear with me!). Is there any way i can move all the files
into another directory, or the root directory, but have the system save
each instance of duplicately named files. In other words, can i move
all three BOB.JPG files into one directory but have the system or a
program automatically number them BOB1.JPG, BOB2.JPG, BOB3.JPG so as
not to lose or overwrite them?

I hope this makes sense, i tried doing it through winzip but couldn't
find a way.

Many thanks.
 
D

Dave Patrick

You may be able to script something. Bear in mind that just because the file
names are the same does not mean the file contents are the same and or the
same version.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
| Greetings
|
| Can anyone suggest a solution to the following query, illustrated best
| by way of example:
|
| e.g. my hard drive has a directory folder called ANIMAL, with
| subdirectory folders DOG, CAT, FISH. Say each subdirectory has a list
| of files, and several filenames are duplicated within each separate
| folder, so there is a file called BOB.JPG in the DOG, CAT and FISH
| directory (bear with me!). Is there any way i can move all the files
| into another directory, or the root directory, but have the system save
| each instance of duplicately named files. In other words, can i move
| all three BOB.JPG files into one directory but have the system or a
| program automatically number them BOB1.JPG, BOB2.JPG, BOB3.JPG so as
| not to lose or overwrite them?
|
| I hope this makes sense, i tried doing it through winzip but couldn't
| find a way.
|
| Many thanks.
|
 
P

Phil Robyn

buffaloes said:
Greetings

Can anyone suggest a solution to the following query, illustrated best
by way of example:

e.g. my hard drive has a directory folder called ANIMAL, with
subdirectory folders DOG, CAT, FISH. Say each subdirectory has a list
of files, and several filenames are duplicated within each separate
folder, so there is a file called BOB.JPG in the DOG, CAT and FISH
directory (bear with me!). Is there any way i can move all the files
into another directory, or the root directory, but have the system save
each instance of duplicately named files. In other words, can i move
all three BOB.JPG files into one directory but have the system or a
program automatically number them BOB1.JPG, BOB2.JPG, BOB3.JPG so as
not to lose or overwrite them?

I hope this makes sense, i tried doing it through winzip but couldn't
find a way.

Many thanks.

- - - - - - - begin screen capture WinXP MCE 2005 SP2 - - - - - - -
c:\cmd>tree /a \animal
Folder PATH listing
Volume serial number is 44E5-91F9
C:\ANIMAL
+---cat
+---dog
\---fish

c:\cmd>dir /s /b /a-d \animal
c:\animal\cat\bob.jpg
c:\animal\dog\bob.jpg
c:\animal\fish\bob.jpg

c:\cmd>demo\bobs
1 file(s) copied.
1 file(s) copied.
1 file(s) copied.

c:\cmd>dir /s /b \znimal
c:\znimal\bob.jpg
c:\znimal\bob1.jpg
c:\znimal\bob2.jpg

c:\cmd>demo\bobs
1 file(s) copied.
1 file(s) copied.
1 file(s) copied.

c:\cmd>dir /s /b \znimal
c:\znimal\bob.jpg
c:\znimal\bob1.jpg
c:\znimal\bob2.jpg
c:\znimal\bob3.jpg
c:\znimal\bob4.jpg
c:\znimal\bob5.jpg

c:\cmd>wyllist demo\Bobs.cmd
==========begin file c:\CMD\DEMO\Bobs.cmd ==========
001. @echo off
002. setlocal
003. for /f "tokens=*" %%a in (
004. 'dir /s /b \animal\bob.jpg'
005. ) do call :main %%a
006. goto :EOF
007. :main
008. if not exist \znimal\%~nx1 copy "%*" \znimal&goto :EOF
009. for /f "tokens=*" %%a in (
010. 'dir /b \znimal\%~n1*.jpg'
011. ) do set last=%%a
012. set last=%last:bob=%
013. if not defined last (set last=1) else (set /a last += 1)
014. copy "%*" \znimal\bob%last%%~x1
015. goto :EOF
==========end file c:\CMD\DEMO\Bobs.cmd ==========

- - - - - - - end screen capture WinXP MCE 2005 SP2 - - - - - - -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top