# I need batch file help



## novicedos (Nov 10, 2003)

My batch file is supposed to zip files and rename them automatically with the "date" of day the batch file is executed. 

Can someone please help me with this!


----------



## coderitr (Oct 12, 2003)

There was another extensive thread similar to this where the poster wanted to move files to subdirectories based on the day of the week that the file was created. Bottom line, I don't know of any environment variable in DOS that will return the current date/time and therefore this may not be possible from a simple batch file. I could be wrong about this though. It is possible to write a program to do what you want using either shell calls or a third party compression library. If the runtime platform is truly DOS (16-bit) then a 16 bit compiler would have to be used to compile the program into an exe. If the runtime is the command prompt of a Windows box then all of the 32-bit Windows stuff is available to use.


----------



## mole (Aug 24, 1999)

Are you running DOS or is this a command prompt window in a version of Windows such as 9x/ME/NT/2K/XP? Which version?

If in a command prompt window on NT/2K/XP, you have access to many commnds that simplify what you want to do compared to earlier versions of Windows and plain DOS.


----------



## zephyr (Nov 6, 2003)

What you want to do is possible but not too easy. You'll need to do some serious homework re: environmental variables and a good starting place is here.


----------



## codejockey (Feb 11, 2002)

The thread mentioned earlier may help: http://forums.techguy.org/showthread.php?s=&threadid=175994. As another poster mentioned, you will need to distinguish between executing your script in a "real" DOS enviornment or in a command window under Windoze 2000/XP. The thread shows how to determine the day of the week for the current date in both environments, and how to put this information in an environment variable. Since I provided the examples, it's only fair that I'm available to answer any questions, as well )).

A few more specifics would also be helpful (e.g., are you creating more than one zip archive for a specific day? is there a file naming convention that should be followed? etc.).

Hope this helps -- and additional info appreciated.


----------



## novicedos (Nov 10, 2003)

thanks for your help everyone!


----------



## zephyr (Nov 6, 2003)

I'll share some insight into a freeware utility that many people haven't discovered yet.

With the following single command line:

xxcopy c:\calendar\ G:\calendarBackup\/$WWW-YYYY-MM-DD$\ /EC /W

It creates the folder:

G:\calendarBackup\TUE-2003-11-11

Which contains all the files in the source folder. That sure beats fooling around with Environmental Variables in many cases. This can easily be adapted to a batch file along with the Winzip command line operator and accomplish what you originally asked for.

You can eliminate the /EC (lets you see the proposed re-created command prior to running it) and the /W (pauses for confirmation) You can also insert the current time by adding the switch $TIME$. There are over 160 switches available!

It's a truly remarkable utility.

XXCOPY


----------

