@ Echo off
Setlocal enabledelayedexpansion
Title % date % time :~, 8% by LiaoNing Sunray Software Technology
: Defines the database SID.
Set SID = sryx254
: Defines an array of user names (separated by spaces, for example, user1 user2 user3)
Set userArr = user1 user2 user3
Set pswdArr = password1 password2 password3
: Specified number of days to delete
Set daysAgo = 7
: Specifies the backup path.
Set filePath = E: \ dmp_beifen \
: Defines the internal variables of the script.
Set time _ = % time: = 0%
Set fileName = % date :~ 0, 4% % date :~ 5, 2% % date :~ 8, 2% _ % time _:~ 0, 2% % time _:~ 3, 2%. dmp
Set newDir = % date :~ 0, 10% \
: Create a folder named after the day
If not exist % filePath % md % filePath %
If not exist % filePath % newDir % md % filePath % newDir %
: Export data
Set/a n = 1
Call: sub userArr %
Call: sub pswdArr %
Set/a arrLength = nuserArr
: Loop
Exp! UserArr % n %! /! PswdArr % n %! @ % SID % file = % filePath % newDir %! UserArr % n %! _ % FileName %
: Echo test display! UserArr % n %! /! PswdArr % n %!
If % n % lss % arrLength % set/a "n + = 1" & goto loop
Goto next
: Sub
Set % 1% n % = % 2
If not "% 3" = "" (set/a n + = 1
Shift/2 & goto sub)
Set/a "n % 1 = n, n = 1" & goto: eof
: Next
: Delete data N days ago
Set d = % date :~ 0, 10%
Mshta vbscript: createobject ("scripting. filesystemobject "). opentextfile ("temp.txt", 2, true ). write (FormatDateTime (dateadd ("d",-% daysAgo % + 1, "% d %"), vb1_date) (window. close)
For/f "tokens = 1 delims =" % I in (temp.txt) do set t1 = % I
For/f "delims =" % I in ('dir/ad/B % filePath % ') do (
Set t2 = % I
Set t3 =! T2 :~ 0, 10!
If! T3! Lss! T1! Rd/s/q "% filePath % I ")
Del/f temp.txt
Note that you must also set the short date and long date format to "yyyy-mm-dd" in the control panel ", otherwise, the data that was last deleted N days ago may be faulty (the backup file was deleted several days later)
From a running pig