>I want to move a load of files into alpha sorted directories. Often
>the list of files I want to move is well over 5000 and I am currently
>using the /-y switch.
>
>However, every time it has a filename conflict, it asks me if I want
>to overwrite. After doing it for x hundred files, this gets a bit
>tedious pressing 'N' and then ENTER for each one.
>
>I want to automatically allow it to say no to overwriting so I can
>rename the remaining files and re-run the batch file.
>
>From my base directory, the structure is:
>BASE
>......SORTED
>...............A
>...............B
>...............C
>etc to Z...then
>..............ZIPS
>..............MOVIES
>..............NUMERIC
How about appending a number automatically to files with the same name?
If not, in your code you would do something like this fro the copy command:
if not exist "%filepath%\%filename%" copy "%filename%" "%filepath%\"
I believe that a template for what you are looking for may be something
like: (one line)
for %%i in (a b c) do if exist \sourcedir\%%i*.* for %%q in
(\sourcedir\%%i*) do if not exist "\destdir\%%~nxq" if not exist
"\destdir\%%~snxq" ECHO move "%%~fq" \destdir\
Where the ECHO is for safety.
That is, for matching filenames (if they exist) make sure that neither the
long filename nor the short filename exists in the destination directory and
if neither exists, move the file.
I've observed however that wit certain "nasty" filenames (containing
multiple-% for instance) the move is skipped, and also that sometimes the
file is COPIED, not moved - which I've seen before with the MOVE command.
Have you looked at XXCOPY? I believe the /BB switch does what you want and
xxcopy does a whole lot more.
--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
/-y is the default. to prompt.
/- means don't. like dir /o-h all non hidden files, instead of
dir /oh
/y "supporesses the prompt and confirms it. It says yes to the prompt
and doesn't show the prompt.
>
> >However, every time it has a filename conflict, it asks me if I want
> >to overwrite. After doing it for x hundred files, this gets a bit
> >tedious pressing 'N' and then ENTER for each one.
>
> >I want to automatically allow it to say no to overwriting so I can
> >rename the remaining files and re-run the batch file.
>
sounds like another way to solve the problem would be
md asdf
::move out all files with the same name in src and dest to the asdf
directory
move allthosefiles asdf
move *.* \dest <-- moves all (these have different names), to \dest
rename accordingly.
ren *.* R*.* <-- something like that or one by one
you may want to test that no files in dest share those names
move *.* \dest
..
I was thinking about echo nnnnnn| xcopy ...
it works for echo sddssdf | dir /p
Fortunately , is a simple Y or N, and not a really stupid prompt of F
or D.
Because the dest directory exists.
I did try
c:\adsf>echo n| xcopy *.* \asdf2
that was weird, it didn't copy files a and b, but it copied some
others. then it stopped (*.* should include a and b, in DOS.. And,
* doesn't do them either, though i think one is meant to use *.*)
/c didn't help it , /c is meant to continue if errors occur.