# Adding a switch to a batch file



## online_fixes (Jul 6, 2005)

I use the following daily to Scan and backup any changed files in a small system I have here.

@echo off
echo %date% - %time% > R:\xcopy.log
xcopy "C:\Documents and Settings\Administrator\Desktop\Restore_Folder_1\*.*" R:\Restore_Folder_1\ /c /s /r /d /y /i >> R:\xcopy.log

Does anyone know of a switch that can be added to remove empty folders or folders of a certain age?

Thanks 

Gary


----------



## Squashman (Apr 4, 2003)

I would look into using XXcopy. I believe it has the functionality you need.
http://www.xxcopy.com/index.htm


----------



## online_fixes (Jul 6, 2005)

I will look into xxcopy!

Gary


----------



## online_fixes (Jul 6, 2005)

I took a look at XXcopy and I would like to keep the file in plain old dos if anyone else out there has an answer?

Thanks 
Gary


----------



## ghostdog74 (Dec 7, 2005)

online_fixes said:


> I took a look at XXcopy and I would like to keep the file in plain old dos if anyone else out there has an answer?
> 
> Thanks
> Gary


hi
below are suggestions if you want plain old dos..hope i read your qns correctly...

to remove empty directory , you could just use rmdir. By default, rmdir(on my system) would not remove directories that are not empty.

rmdir somedir > nul 2>&1

for removing files of certain age, you can check out the xcopy /D:m-d-y switch. I donno whether your xcopy has this option or not..
Manipulate your batch such that it copies the files with the date you want, to the backup , and then you can remove the old directory..


----------



## blaqDeaph (Nov 22, 2005)

Yea, RMDIR to remove empty directories.
To Remove directories of a certain age, the only thing i can think of is making a copy of folders that are not that age (using xcopy) and deleting all the folders, then copying back using xcopy.


----------



## online_fixes (Jul 6, 2005)

Thank you all!
I think the last two entries by ghostdog74 and blaqDeaph will help me out!

Happy New Year!!

Gary


----------



## blaqDeaph (Nov 22, 2005)

Although I should add that if you have basic knowledge of C programming, you could do this more efficiently. Also, you can choose to check some briefcase programs.


----------

