Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DOS copy file 2

Status
Not open for further replies.

jodjim

Programmer
Nov 5, 2004
69
CA
What's the syntax in DOS commands to copy Filename1.txt to Filename1+Today.txt

Not sure if this is the right forum but would appreciate any help.

Thanks
 
This is the error i got with ur command.

"Cannot perform a cyclic copy"

--
mobajwa
 
the syntax is xcopy path\filename path..

here is an example i've used in the past.

xcopy l:\nw\HRSP57 c:\home
 
the switch "/e" copies the directory and subdirectory. the switch "/w" prompts you before copying..
 
From what i understood, i thought the user wanted to copy an image of the file with the DATE in the file name, maybe for backup purposes.

Heres what i want to know.
suppose i have a file abc.txt

now what would i put in the batch file to take a backup of this file with the current date ..

lets say i want c:\abc.txt to be copied to d:\abc+currentdate.txt

now see if you can come up with the command !

--mobajwa
 
xcopy does not offer what ur requesting but if i can come up with a solution i'll post it..
 
Thanks mobajwa for reading my mind. That's exactly what I was looking for. Another option though is instead of Filename1+Currentdate.txt, how about the Filename1+Date Modified.txt

Thanks, haga147. Looking forward to your next post.
 
I have this but I am still working on it a little. It copies the file and appends the date like you want but it keeps asking if abc+blah.txt is suppose to be a directory or a text file. So that make automating harder. But here you go so u can play too.




set todaydate=
for /f "tokens=1-2 delims= " %%A in ('date /t') do set todaydate=%%B
for /f "tokens=1-3 delims=/" %%A in ("%todaydate%") do set todaydate=%%A%%B%%C
rem mkdir %todaydate%

xcopy c:\temp\abc.txt c:\temp\abc+%todaydate%.txt
 
I should point out that djtech2, I think that was his name, did most of the work so give him a little credit to>

thread931-1016788
 
OK, lets go with this. Sorry, but you are not gonna be able to use a + sign:


set todaydate=
for /f "tokens=1-2 delims= " %%A in ('date /t') do set todaydate=%%B
for /f "tokens=1-3 delims=/" %%A in ("%todaydate%") do set todaydate=%%A%%B%%C


copy c:\temp\abc.txt c:\temp\abc_%todaydate%.txt
 
LOL

I tried to copy a test.txt and the resulting file is called test_%todaydate%.txt !!!!!

can u please walk us through this file that u made..

-
mobajwa

After the game ,the king and the pawn , both go in the same box.
 
Hey Stiddy.. My bad !!! I tried it gain and it works. created a file abc_03042005.txt for my abc.txt

Excellent work !

Great Work Stiddy & djtech2 !!

-
mobajwa

After the game ,the king and the pawn , both go in the same box.
 
Got it and it's working! Thanks, Stiddy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top