home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 1710
Discussions: 188,401, Posts: 2,243,608, Members: 232,631
Old September 15th, 2005, 01:10 PM   Digg it!   #1 (permalink)
Member
 
Join Date: Apr 2003
Location: VA
Posts: 250
Send a message via AIM to Jokerswild
Batch File Help

I have a batch file on my USB Drive. When I run it, it makes a backup copy of everything that has been updated on the drive onto my hard drive. I want to make the batch file automatically creates a folder with that days date and move the backup copy there. So it would create on folder for today, one folder for tomorrow, etc.

What syntax would I need to throw in there?

Jokerswild is offline   Reply With Quote
Old September 15th, 2005, 03:04 PM     #2 (permalink)
Senior Member
 
saladbarkid's Avatar
 
Join Date: Apr 2002
Location: TechIMO
Posts: 539
I found this online:

Here is the website, so the author gets his credit:
http://www.tech-recipes.com/computer...g_tips956.html

Code:
echo on
@REM Seamonkey's quick date batch (MMDDYYYY format)
@REM Setups %date variable
@REM First parses month, day, and year into mm , dd, yyyy formats and then combines to be MMDDYYYY

FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET date=%mm%%dd%%yyyy%

Just copy this text into a batch file; run the batch file; In dos, change to the directory of the folder you wish to change; Type "ren foldername %date%"

(Do not type the quotes)Replace foldername with the name of the folder you wish to change the name of.
__________________
20" iMac 2.16GHz / 1GB RAM / 250GB HDD / 8x DVDRW / OS 10.5

saladbarkid is offline   Reply With Quote
Old September 15th, 2005, 03:23 PM     #3 (permalink)
Member
 
Join Date: Apr 2003
Location: VA
Posts: 250
Send a message via AIM to Jokerswild
Here is what I have so far :


@Echo Off

Echo This Program is for Copying Files.
Echo Used to create backup copy of flash disk

mkdir "F:\Backup"


xcopy /w /d /y /h /e "C:\Documents and Settings\wb277600\Favorites"
"F:\Backup"


Echo Copy complete
Pause

Echo Hopefully this will rename the folder to today's date.

REN "Backup" "%mm%%dd%%yyyy%"
Echo Rename Complete
Pause


Where you see the second ECHO command, followed by (what I think is...) the rename command, I just need the command that will insert the date.

Jokerswild is offline   Reply With Quote
Old September 15th, 2005, 03:44 PM     #4 (permalink)
Senior Member
 
saladbarkid's Avatar
 
Join Date: Apr 2002
Location: TechIMO
Posts: 539
Tell it to run the batch code above then use REN "Backup" %date%

That should do it.
saladbarkid is offline   Reply With Quote
Old September 15th, 2005, 09:21 PM     #5 (permalink)
Member
 
Join Date: Apr 2003
Location: VA
Posts: 250
Send a message via AIM to Jokerswild
That seems like it should work but whenever I run it, I get an error message "The syntax of the command is incorrect". I've tried making a test file and running the command directley from the command prompt but receive the same error.

I've tried several combos like %d%, %date......
Jokerswild is offline   Reply With Quote
Old September 16th, 2005, 02:12 PM     #6 (permalink)
Senior Member
 
saladbarkid's Avatar
 
Join Date: Apr 2002
Location: TechIMO
Posts: 539
Hmmm...that's odd. It ran fine for me on 2000. Try copying the code from the website link I provided and add it into a batch. Just make sure you are not adding in the ren command into the batch - that needs to run after the batch is run.
saladbarkid is offline   Reply With Quote
Old September 16th, 2005, 02:42 PM     #7 (permalink)
Member
 
Join Date: Apr 2003
Location: VA
Posts: 250
Send a message via AIM to Jokerswild
I finally got it to work, I used the code below which is similar to what you showed me in that link.


Echo Hopefully this will rename the folder to today's date.


Rem Get Day,Mth & Year from %Date%
set Day=%Date:~0,2%
set Mth=%Date:~3,2%
set Yr=%Date:~6,4%


ren "backup" %Day%-%Mth%-%Yr%


Pause



Any idea how to squeeze the time feature in there as well? I've tried this line

set time=%time.....
but I don't know what the put after that.

I'm not batch-file smart.
Jokerswild is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch File Help PeterGriffin General Tech Discussion 0 October 28th, 2004 03:52 PM
Batch File Help Crackerjack Applications and Operating Systems 6 October 14th, 2003 11:01 AM
Help with Batch File PeterGriffin General Tech Discussion 3 October 2nd, 2003 01:41 PM
batch file help glue_head Applications and Operating Systems 9 August 29th, 2003 06:44 PM
Batch file ribster Technical Support 3 May 12th, 2003 09:53 AM

Most Active Discussions
Is It Just Me? (2906)
3-days in and no threads about Gaza (161)
Unarmed man on his stomach shot by .. (6)
New Build ( Finally ) (7)
CPU wont boot (7)
Building a gaming computer advice (5)
I think I just killed my computer w.. (24)
RCA 52Inch HDTV wont turn on (5)
Folderchat Weekday thread (444)
Recent Discussions
Laptop proccesor to desktop mob.. (2)
Please help! multiple problems! (4)
RCA 52Inch HDTV wont turn on (5)
New Build ( Finally ) (7)
Common Spyware Solutions (97)
How do you move a hard-drive to.. (4)
What is the best external enclo.. (0)
Partition Magic 7.0 (Unallocate.. (17)
For cheap price and good qualit.. (1)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 04:16 AM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28