6 replies
You can probably manage with .bat files. Here is an example, based on keyboard input of the first file creation date you want to keep in the folders.
How to call the routine:
filedel 07-12-2005
It is assumed that both routines are stored at the root of the directory structure where your Outgoing directories are.
Here is the main routine filedel.bat:
@echo off
set date = %1
@echo date = %date%
@echo press Enter to continue
@echo press Ctrl-C to stop the deletion of older files from Outgoing
pause
@echo starting loop
for /F %%i in ('dir /AD /B /S Outgoing*') do filesub.bat %date% "%%i"
@echo end of loop
... and here is the subroutine filesub.bat:
@echo off
@echo parameter 1: date mm-dd-yyyy %1
@echo parameter 2: directory path %2
@echo create an empty work directory
rmdir /S /Q workdir
mkdir workdir
@echo copy files newer than the date to workdir
xcopy %2\*.* workdir\. /D:%1 /C /Q /K /X
@echo delete all files from directory
del /Q %2\*.*
@echo copy files back from workdir
xcopy workdir\*.* %2\. /C /Q /K /O
Enjoy!
Oops, the main routine may not always work. Replace it with this version which prompts for the date, instead of getting it as a command line parameter:
@echo off
set /P date_in=Enter date dd-mm-yyyy:
@echo date = %date_in%
@echo press Enter to continue
@echo press Ctrl-C to stop the deletion of older files from Outgoing
pause
@echo starting loop
for /F %%i in ('dir /AD /B /S Outgoing*') do filesub.bat %date_in% "%%i"
@echo end of loop
by shempdog
The answer was sound and it actually works, I had already figured it out myself. But I promised the points, and He'll get them
by shempdog
could you please send the VB script which takes the back up of the files which are older than a week, 7 days from one folder on the network and then deletes these files from the source folder, .
Help will be much appreciated, as i need this script in a very short time.Tried out various script can't fulfill both of my purposes i.e. >
1) taking the backup of the files in a particular folder, datewise
2) delete from the source directory.
Thanks in advance.
by shempdog
This discussion is closed to new replies.
Trending Desktop posts
Sort by Trending