Computing.Net > Forums > Disk Operating System > Script to copy and create Unique name

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Script to copy and create Unique name

Reply to Message Icon

Name: Aldo
Date: July 11, 2002 at 08:32:52 Pacific
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: TKaz
Date: July 11, 2002 at 08:52:07 Pacific
Reply:

I think this is what you need...
copy a:\a.txt x:\dir\a2.txt

TKaz


0

Response Number 2
Name: Secret_Doom
Date: July 11, 2002 at 12:51:38 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Script to copy and create Unique name

script to copy the newest file www.computing.net/answers/dos/script-to-copy-the-newest-file/13858.html

Script to find and open file. Help. www.computing.net/answers/dos/script-to-find-and-open-file-help/16691.html

Copy, increment, and delete file www.computing.net/answers/dos/copy-increment-and-delete-file/16397.html