Good morning friends, I tell them I have the following script, and what I need is that when I create folders on the first and last line, believe me the day before the date. Osea if today is 30, I believe it is dated 29. Is there any way? Thank you!
Greetings!
SET FOLDER=%date:~6,4%-%date:~3,2%-%date:~0,2%
SET FOLDER1="Cocuments and SettingsadministradorLocal SettingsApplication DataMicrosoftWindows NTNTBackupdata*.log"
mkdir %FOLDER%_Diario
MOVE E:backupDiario.bkf E:backup%FOLDER%_Diario
mkdir E:backup%FOLDER%_DiarioBases
XCOPY E:bases*.* E:backup%FOLDER%_DiarioBases /e/c/h/k/o/x/y
xcopy %FOLDER1% E:backup%FOLDER%_Diario /D:%date:~3,2%-%date:~0,2%-%date:~6,4% /e/c/h/k/o/x/y
[Help] Create folder with earlier
Moderator: DosItHelp
-
- Posts: 5
- Joined: 21 Jan 2013 07:09
Re: [Help] Create folder with earlier
Hi,
the above code should work fine it uses the julian calender to subract a day from the current date..
Code: Select all
@ECHO OFF
set input2=-1
SET cDays=%input2%
set /a GMonth=%Date:~3,2%
set /a GDay=%Date:~0,2%
set /a GYear=%Date:~6,4%
:: Convert the parsed Gregorian date to Julian
CALL :JDate %GMonth% %GDay% %GYear%
:: Add or subtract the specified number of days
IF "%cDays:~0,1%"=="-" (
SET /A NewJDate = %JDate% - %cDays:~1%
) ELSE (
SET /A NewJDate = %JDate% + %cDays%
ECHO Days added : %cDays%
)
:: Convert the new Julian date back to Gregorian again
CALL :GDate %NewJDate%
:: Display the result
SET OUTPUT=%GDate%
:: this is the code you have written
SET FOLDER=%OUTPUT:~4,4%-%OUTPUT:~0,2%-%OUTPUT:~2,2%
SET FOLDER1="Cocuments and SettingsadministradorLocal SettingsApplication DataMicrosoftWindows NTNTBackupdata*.log"
mkdir %FOLDER%_Diario
MOVE E:backupDiario.bkf E:backup%FOLDER%_Diario
mkdir E:backup%FOLDER%_DiarioBases
XCOPY E:bases*.* E:backup%FOLDER%_DiarioBases /e/c/h/k/o/x/y
xcopy %FOLDER1% E:backup%FOLDER%_Diario /D:%OUTPUT:~2,2%-%OUTPUT:~0,2%-%OUTPUT:~4,4% /e/c/h/k/o/x/y
:GDate
:: Convert Julian date back to "normal" Gregorian date
:: Argument : Julian date
:: Returns : MMDDYYYY
SET /A P = %1 + 68569
SET /A Q = 4 * %P% / 146097
SET /A R = %P% - ( 146097 * %Q% +3 ) / 4
SET /A S = 4000 * ( %R% + 1 ) / 1461001
SET /A T = %R% - 1461 * %S% / 4 + 31
SET /A U = 80 * %T% / 2447
SET /A V = %U% / 11
SET /A GYear = 100 * ( %Q% - 49 ) + %S% + %V%
SET /A GMonth = %U% + 2 - 12 * %V%
SET /A GDay = %T% - 2447 * %U% / 80
:: Clean up the mess
FOR %%A IN (P Q R S T U V) DO SET %%A=
:: Add leading zeroes
IF 1%GMonth% LSS 20 SET GMonth=0%GMonth%
IF 1%GDay% LSS 20 SET GDay=0%GDay%
:: Return value
SET GDate=%GMonth%%GDay%%GYear%
GOTO:EOF
:JDate
:: Convert date to Julian
:: Arguments : MM DD YYYY
:: Returns : Julian date
:: First strip leading zeroes
SET MM=%1
SET DD=%2
IF %MM:~0,1% EQU 0 SET MM=%MM:~1%
IF %DD:~0,1% EQU 0 SET DD=%DD:~1%
SET /A Month1 = ( %MM% - 14 ) / 12
SET /A Year1 = %3 + 4800
SET /A JDate = 1461 * ( %Year1% + %Month1% ) / 4 + 367 * ( %MM% - 2 -12 * %Month1% ) / 12 - ( 3 * ( ( %Year1% + %Month1% + 100 ) / 100 ) ) / 4 + %DD% - 32075
FOR %%A IN (Month1 Year1) DO SET %%A=
GOTO:EOF
the above code should work fine it uses the julian calender to subract a day from the current date..
Re: [Help] Create folder with earlier
First of all sorry for my poor English. It really is amazing the work you did friend! Everything works to perfection! Quisas was easy for you, but for me a world! Thank you so much for taking the time to edit the script! Greetings!