Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello,
I am trying to figure out how to copy file a.txt from floppy to x:\dir\a1.txt. Of course, the first time is easy. However, I need the bat to be able to recognize a1.txt and rename the next copy to a2.txt. This will allow me to keep a history. Can this be done with a bat?Thanks,
Aldo

I think he wants the batch file to copy a:\a.txt to x:\dir\a1.txt on the first time it is runned. On the second time, the file would be copied to x:\dir\a2.txt and so on. Is that it?
Well, if that's it, this will do it:
===== BATCH SCRIPT BEGIN =====
@echo off
echo e100'SET %%1='> %TEMP%.\TEMP.DAT
for %%? in (rcx 7 w q) do echo %%?>> %TEMP%.\TEMP.DAT
type nul> %TEMP%.\TEMP.BAT
DEBUG %TEMP%.\TEMP.BAT < %TEMP%.\TEMP.DAT > nul
echo a0.txt> %TEMP%.\TEMP.DAT
set dircm_=%dircmd%
set dircmd=
dir/b/l x:\dir\a*.txt >> %TEMP%.\TEMP.DAT
set dircmd=%dircm_%
set dircm_=
FIND/c ".txt" < %TEMP%.\TEMP.DAT >> %TEMP%.\TEMP.BAT
call %TEMP%.\TEMP.BAT NUM
del %TEMP%.\TEMP.?AT
copy a:\a.txt x:\dir\a%NUM%.txt
set NUM=
===== BATCH SCRIPT END =====Watch out for line wrapping!
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |