# Solved: copy files using DOS created or modified



## hemanth_5582 (Mar 11, 2009)

hai 

I am using Windows XP Operating System. Is anyone can give the solution to copy files using DOS (Old), created or modified today


----------



## steelersfan32 (Feb 17, 2009)

What do you mean "created or modified"? The command to copy a file under DOS is " copy (place filename here) C:\\(place to put the copy at) ". The blue letters are what you change.


----------



## Squashman (Apr 4, 2003)

Easy enough to do with Xcopy with the /D option if you just want to use the modified date. Robocopy can do it with either data I believe.

If you want to specify the data value at a dos prompt using DIR you need to specify the /T flag. So if you wanted to copy all files created 3/10/09, you could do something like this in a batch file.


```
@echo off
setlocal
:: setting create date
set cdate=03/10/09
for /f "tokens=1,4*" %%a in ('dir /a-d /TC') do if  "%%a"=="%cdate%" copy "%%c" c:\backup
```


----------



## TheOutcaste (Aug 8, 2007)

Robocopy can use Last Modified, or Last Access, but not the Creation date. Don't know why they didn't include creation date as an option.
You'd need to use the For loop and Dir to use the creation date:

/MAXAGE:n
Excludes files with a Last Modified Date older than n days or
specified date. If n is less than 1900, then n is expressed in
days. Otherwise, n is a date expressed as YYYYMMDD.

 /MINAGE:n
Excludes files with a Last Modified Date newer than n days or
specified date. If n is less than 1900, then n is expressed in
[days. Otherwise, n is a date expressed as YYYYMMDD.

 /MAXLAD:n
Excludes files with a Last Access Date older than n days or
specified date. If n is less than 1900, then n is expressed in
days. Otherwise, n is a date expressed as YYYYMMDD.

 /MINLAD:n
Excludes files with a Last Access Date newer than n days or
specified date. If n is less than 1900, then n is expressed in
days. Otherwise, n is a date expressed as YYYYMMDD.


Jerry


----------



## hemanth_5582 (Mar 11, 2009)

Squashman said:


> Easy enough to do with Xcopy with the /D option if you just want to use the modified date. Robocopy can do it with either data I believe.
> 
> If you want to specify the data value at a dos prompt using DIR you need to specify the /T flag. So if you wanted to copy all files created 3/10/09, you could do something like this in a batch file.
> 
> ...


thanks four ur code
but it is not working

I am using the following code to copy files to copy my files

xcopy c:\*.*/y d:\bakup/s/e
*********************

This command will copy all the files located in C:\ drive when i execute the batch file, it will take maximum time. But i want to create a batch file with a control i.e., files created or modified today (cdate=sys.date). I am expecting you can solve my problem.


----------



## Squashman (Apr 4, 2003)

Can you tell me what is not working with the code or why it is not working for you? Just telling me it is not working doesn't really tell me anything. Execute it from a cmd prompt and tell if it gives you any error messages.

Can you define what you mean by sys.date? I have no idea what that means.


----------



## Squashman (Apr 4, 2003)

hemanth_5582 said:


> xcopy c:\*.*/y d:\bakup/s/e
> ***


Did you look at my suggestion above about using the /D switch.


----------



## TheOutcaste (Aug 8, 2007)

Just guessing, but the cdate needs to be a 4 digit year to match the *Dir* output on my system, so that might be the case.
set cdate=03/10/2009
And depending on regional settings, might need to use a delimiter other than a slash.

If what you are wanting to do is backup your files, then copying only those modified or created "today" can often miss backing up files.
Example:
You create a file at school on Monday, work on it Tuesday and Wednesday.
Thursday you move it to your computer. Then you run your backup script.

It will *never* be backed up. The modified date is Wednesday. If you think it will be copied because it was created on your PC on Thursday, it won't. The creation date is _Monday_, not Thursday, because you _moved_ the file, which preserves the creation date.
Plus, with this process, if you forget to run your script one day, all files modified/created on that day would be missed.

As already suggested, you want to use the */D* option with *Xcopy*. This will copy all _New_ files, regardless of creation date, as well as files that have been modified since they were last copied.

What is it you are trying to accomplish? You can't use this type of copy to restore the drive in the event of a failure. Especially without using the switches to copy hidden and system files, and to overwrite read-only files that get modified. Plus, files in use (like the registry) won't be copied, and without the C switch, the first error will stop the entire copy operation.

If you are wanting to backup the whole drive, the built-in backup program would be a better choice, as it can backup the registry _and_ all files that are in use. As well as compressing the data so it takes up less space on your backup drive.

The closest you can come to a complete backup with Xcopy would be this:

*Xcopy /CDEHKRY C:\*.* D:\bakup*

If the destination is formatted NTFS, you may want to add the *O* or *X* switch.
Plus it would be best to first run this:

*Xcopy /ET C:\*.* D:\bakup*

to create the directory structure first. Helps to reduce fragmentation.

Xcopy does not remove files that no longer exist. So temp files, browser and java cache folders and the like will need to be cleaned out on a regular basis. Using *Robocopy* with the */purge* option enabled every few days would be a better choice.

Jerry


----------



## Squashman (Apr 4, 2003)

TheOutcaste said:


> Just guessing, but the cdate needs to be a 4 digit year to match the *Dir* output on my system, so that might be the case.
> set cdate=03/10/2009
> And depending on regional settings, might need to use a delimiter other than a slash.


Yeah, I forgot. Our company sets the regional setting to a two digit year because we have some internal app that uses it that way so that is the way it has to be. Apparently they don't know how to program the app so that anyone can set their regional settings they way they want it to. I made the mistake of changing it and then I couldn't track my job flow after that.


----------



## hemanth_5582 (Mar 11, 2009)

Thanks for your suggestion. But, I haven't that problem; because I runthis script at shutdown, so i am able to bakup each and every file created and modified in between login and shutdown. 

your code is not working /D is not working in command promt


so send another one


----------



## hemanth_5582 (Mar 11, 2009)

Thank you 
my problem is sloved


----------



## Squashman (Apr 4, 2003)

hemanth_5582 said:


> Thank you
> my problem is sloved


Usually a good idea to post what solved your problem and then mark the thread Solved with the the Thread Tools link at the top of the page.


----------



## hemanth_5582 (Mar 11, 2009)

I m need to set potriat for the 1st page and landscape for the 2nd page in the same excel work sheet. anyone can help me


----------



## Ent (Apr 11, 2009)

If you don't mind my asking, why do you need to do this? Are the pages linked together in some way that you can't print them separately?

One entirely *not technical *workaround would be to print twice, and make aeroplanes from the two sheets not formated as you want them. Or only print pg 1 when portrait etc


----------



## hemanth_5582 (Mar 11, 2009)

Thanks for your suggestion, but i need to work in the same worksheet only. If you can tell, how to set the diffierent page sizes in the same worksheet, please send to me.
thanks with regards


----------



## Squashman (Apr 4, 2003)

You probably should have started another thread instead of replying to this thread.


----------

