Do Not Sell My Personal Information Jump to content


  • Join The Club

    Join the Lexus Owners Club and be part of the Community. It's FREE!

     

It Related Question


rhaines
 Share

Recommended Posts

Help as an interim measure until the tape drive arrives I needto setup a little batch file to copy a local backup file to another machine, this will be backed up to the same file daily so need to enter into the batch file a way of creating a driectory with the days date in it, we can't just overwrite the daily backup for obvious reasons...

Anyone remember how to create a folder with the days date in it ?

Link to comment
Share on other sites

thanks matey...

md or mkdir was the easy bit I need the name to be variable, automatically created with the current days date, I dont think i explained myself to well :)

I know have a VB Script form a friend on IMOC so now just have to figure out how to automatically change to the correct folder so I can create the batchfile....

Cheers

Ryan

Link to comment
Share on other sites

Hi rhaines,

I assume your trying to backup a file to a directory.

Therefore why create a new backup directory each time you wish to do a backup.

Why not backup the file into the same directory, but just call it the backup date.

i.e. If the file you wish to backlup is called rhaines.doc

why not copy this file into a backup directory and call it 24-07-2003.doc.

You will have a new file in your backup directory for each day you run the backup.

The batchfile will look like this

Varibles are in red do you can change them

Assumes file to be backed up is in root directory and backup directory will be made in there too.

------- begins here----

@echo off

cls

@echo.

@echo This will backup the file rhaines wants to keep

@echo.

@echo into a directory called BACKUP

@echo.

@echo File will be in C:\BACKUP

@echo.

pause

REM This line checks for the existance of the backup directory.

REM And if it doesn't exist, creates it.

IF NOT EXIST C:\BACKUP MD C:\BACKUP

REM This line sets the current date to a variable called CURDATE

REM This will then be used as the file name

SET CURDATE=%DATE:~4,2%-%DATE:~7,2%-%DATE:~10,4%

REM This line copies the original file and renames it to the current date as set above

copy rhaines.doc C:\BACKUP\%CURDATE%.doc

@echo.

@echo Congratulations, the file has now been copied to C:\BACKUP directory

@echo.

------- End of file --------

hope this helps :winky:

Link to comment
Share on other sites

Thanks buddy, nearly there, says there is an error in the file though :( looks like the CURDATE line....

Was playing with this which someone else sent me but can't get it to add the date on only the month and the year !!

for /f "tokens=2-4 delims=/ " %%a in ('DATE /T') do set dirName=c:\bk%%c%%b%%a%%c

MD %dirName%

Link to comment
Share on other sites


Thanks buddy, nearly there, says there is an error in the file though :( looks like the CURDATE line....

Probably caused by me adding colour to my post.

Here it is again this time cut & paste from the actual batch file

---- begin ---

@echo off

cls

@echo.

@echo This will backup the file rhaines wants to keep

@echo into a directory called backup

@echo File will be in C:\backup

pause

REM This line checks for the existance of the backup directory.

REM And if it doesn't exist, creates it.

IF NOT EXIST C:\BACKUP MD C:\BACKUP

REM This line sets the current date to a variable called curdate

REM This will then be used as the file name

SET CURDATE=%DATE:~4,2%-%DATE:~7,2%-%DATE:~10,4%

REM THis line copies the original file and renames it to the current date as set above

copy rhaines.doc c:\backup\%CURDATE%.doc

@echo File has now been copied to C:\BACKUP directory

@echo.

--- end ---

It works on my PC ok.

Could also be a DOS version thingy.

File created is 24-07-2003.doc. And DOS does accept fielnames begining with a number.

If you need it to be only 8 characters long, then change the SET CURDATE to the following:

SET CURDATE=%DATE:~4,2%%DATE:~7,2%%DATE:~10,4%

File created will be 24072003.doc

Link to comment
Share on other sites

OK worked it out, thanks to a colleague on IMOC but thanks for the help (went with the first one that worked :)

Answer was :

for /f "tokens=1-4 delims=/ " %%a in ('DATE /T') do set dirName=c:\bk%%c%%b%%a

MD c:\agrback\%dirName%

copy t:\*.* c:\argback\%dirName%\*.*

Creates withthe date and copies relevant files to that directory....

Cheers

Ryan

Link to comment
Share on other sites

Glad you got it sorted, but still think copying them to a single directory would be better... :winky:

Hey, I just noticed... you changed the conditions.

I need to setup a little batch file to copy a local backup file to another machine..

First you said a single file.

Creates withthe date and copies relevant files to that directory....

Now your backing up *.*

Bah!

Link to comment
Share on other sites

there is only one file in there but was feeling lazy so *.*....

Basically the dir on the server which contains the backup file is mounted on two machines on T:

I needed to move that off the machine but not overright dailyhence the date concern....

All sorted and can forget about it and concentrate on JAAE now :D :D :D

Link to comment
Share on other sites

what was everyone's first DOS version experienced? Mine was MS-DOS 5, but with a cherry on top - I used a thing called 4DOS on top - Man was that the dogs bits for creating usable batch programs.

:offtopic:

Link to comment
Share on other sites

Mine was DOS 3.1....

Was ok for the time but nothing compared to C, Bash or KSH for Batching stuff and scripting IMHO, don't think it's in danger o f going off topic as the problem has now been solved...

Link to comment
Share on other sites


well done... 5p to rhaines.. he he. :)

Where has all the fun gone...

Thankgoodness we've got Linux

find . -print | cpio -ovcC65536 > /dev/rmt0

Ah, I feel much better now... :geek:

Link to comment
Share on other sites

Or if you're bored these work aswell...

% make fire

Make: Don't know how to make fire. Stop.

% why not?

No match.

% gotta light?

No match.

% !1984

1984: Event not found. # (on some systems)

% How's my lovemaking?

Unmatched '.

% [Where is my brain?

Missing ].

% ^How did the s*x change operation go?

Bad substitute.

% man: why did you get a divorce?

man:: Too many arguments.

% %blow

%blow: No such job.

% sh

$ PATH=pretending! /usr/ucb/which sense

no sense in pretending!

% ar m ***

ar: *** does not exist

% make love

Make: Don't know how to make love. Stop.

% sleep with me

bad character

% ^What is saccharine?

Bad substitute.

% drink bottle: cannot open

opener: not found

% cat catfood

cat: cannot open catfood (hoping you dont have a file called catfood here :D)

% cat "food in cans"

cat: can't open food in cans

% man you

No manual entry for you.

% scan for <<"Arnold Schwarzenegger"^J^D

"Arnold Schwarzenegger": << terminator not found

% cat "door: paws too slippery"

cat: cannot open door: paws too slippery

% mkdir yellow_pages; cat > yellow_pages

yellow_pages: Is a directory

% ar x "my love life"

ar: my love life does not exist

% talk Comrade Khruchev

[Your party is not logged on]

% echo '[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq'|dc

GET A LIFE!

% make ' ' bang ' ' with gun

make: Fatal error: Don't know how to make target ` '

Link to comment
Share on other sites

Showing my age here, but I started with Dos 1.0 which didn't support hard disks. Chuffed when I upgraded to 1.2

C was still in it's infancy and B was still the main language...........

Link to comment
Share on other sites

Latest Deals

Lexus Official Store for genuine Lexus parts & accessories

Disclaimer: As the club is an eBay Partner, The club may be compensated if you make a purchase via eBay links

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share






Lexus Owners Club Powered by Invision Community


eBay Disclosure: As the club is an eBay Partner, the club may earn commision if you make a purchase via the clubs eBay links.

DISCLAIMER: Lexusownersclub.co.uk is an independent Lexus forum for owners of Lexus vehicles. The club is not part of Lexus UK nor affiliated with or endorsed by Lexus UK in any way. The material contained in the forums is submitted by the general public and is NOT endorsed by Lexus Owners Club, ACI LTD, Lexus UK or Toyota Motor Corporation. The official Lexus website can be found at http://www.lexus.co.uk
×
  • Create New...