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

Script to copy and create Unique name

Reply to Message Icon

Original Message
Name: Aldo
Date: July 11, 2002 at 08:32:52 Pacific
Subject: Script to copy and create Unique name
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


Report Offensive Message For Removal


Response Number 1
Name: TKaz
Date: July 11, 2002 at 08:52:07 Pacific
Subject: Script to copy and create Unique name
Reply: (edit)

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

TKaz


Report Offensive Follow Up For Removal

Response Number 2
Name: Secret_Doom
Date: July 11, 2002 at 12:51:38 Pacific
Subject: Script to copy and create Unique name
Reply: (edit)

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


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Script to copy and create Unique name

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge