PDA

View Full Version : duplicate filename query


buffaloes
April 2nd 06, 04:34 PM
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.

Dave Patrick
April 2nd 06, 05:12 PM
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

"buffaloes" wrote:
| 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.
|

Phil Robyn
April 2nd 06, 10:18 PM
buffaloes wrote:

> 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 - - - - - - -


--
Phil Robyn
University of California, Berkeley

Google