# batch file



## thrive (Aug 20, 2007)

im new to writing batch files,

I was just wondering how i would go about writing a batch file to cut a folder from one place to another...i would also like to know how to name that folder with todays date if possible...

thanks


----------



## ryanclemson (Aug 6, 2007)

I could be totally wrong but this is from 
http://www.tech-recipes.com/computer_programming_tips956.html

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%

@Then you could add something along the lines of:
move folderName c:\Destination

@then something like:
rename folderName folderName%date

I have no idea if this will work or not but good luck.


----------



## thrive (Aug 20, 2007)

it wont work for just "folderName", dont i need to setup the right dir first so it knows where to find "foldername" ?

move folderName C:\Destination
rename folderName folderName%date

both lines above have inncorect syntax (and yes i did replace foldername and destination with correct names that applies to my situation)


----------



## Squashman (Apr 4, 2003)

Replace FolderName with the folder you want to process.


----------



## thrive (Aug 20, 2007)

am i suppost to replace folderName with the directions to get to it?
such as, C:\Documents and Settings\All Users\file

or just folderName = file ?


----------



## ryanclemson (Aug 6, 2007)

sorry thrive i was in a rush during my post.

yes you will want to replace folderName with the directions to get to it. you could even use the absolute path. perhaps I should've said:

@Then you could add something along the lines of:
move C:\Source C:\Destination


@then something like:
rename C:\folderName C:\folderName%date

EDIT: you might have to place each file name in quotes "C:\Source" to get it to work


----------



## thrive (Aug 20, 2007)

after the move command it says 'Access is denied'


----------



## ghostdog74 (Dec 7, 2005)

don't use "date" as a variable, because its a DOS command itself...use something else, eg,

```
SET mydate=%mm%%dd%%yyyy%
```



> ```
> rename C:\folderName C:\folderName%date
> ```


the above is incorrect. to call the variable value, you use %mydate%.


----------

