how to copy a folder by date?
Moderator: DosItHelp
-
- Posts: 21
- Joined: 11 Dec 2010 10:17
how to copy a folder by date?
how can I copy a folder by date?
I have three folders, and copy that I created to last ... how do I do?
(Of course in batch...)
PLEASE HELP ME....
I have three folders, and copy that I created to last ... how do I do?
(Of course in batch...)
PLEASE HELP ME....
Re: how to copy a folder by date?
This may help:
Regards
aGerman
Code: Select all
@echo off &setlocal
set "rootfolder=C:\where\the\folders\are\placed"
set "destination=C:\where\the\latest\folder\should\be\copied"
pushd "%rootfolder%" ||goto :eof
for /f "delims=" %%a in ('dir /ad /b /od') do set "latest=%%~a"
xcopy "%latest%" "%destination%\%latest%" /s/e/i/q/g/h/r/k/y
popd
Regards
aGerman
-
- Posts: 21
- Joined: 11 Dec 2010 10:17
Re: how to copy a folder by date?
aGerman wrote:This may help:Code: Select all
@echo off &setlocal
set "rootfolder=C:\where\the\folders\are\placed"
set "destination=C:\where\the\latest\folder\should\be\copied"
pushd "%rootfolder%" ||goto :eof
for /f "delims=" %%a in ('dir /ad /b /od') do set "latest=%%~a"
xcopy "%latest%" "%destination%\%latest%" /s/e/i/q/g/h/r/k/y
popd
Regards
aGerman
thanks a lot! works fine ...
I can explain the commands that you used? For example, what does "| |" or "& setlocal" and "latest =%% ~ a"??
thanks again ...
Re: how to copy a folder by date?
walter4991 wrote:what does "||"
If pushd fails then goto :eof (quit the batch) will proceeded.
walter4991 wrote:or "& setlocal"
You probably don't need it. It's just to protect you from wrong values if you run several batch files in the same environment (e.g. by dropping them onto a a command prompt).
walter4991 wrote:and "latest=%%~a"??
The tilde (~) would remove enclosing quotes from the value in %%a.
Regards
aGerman
-
- Posts: 21
- Joined: 11 Dec 2010 10:17
Re: how to copy a folder by date?
thanks a lot ... you are great ...
one last thing ... if I want to read a set of variables. ini file how can I do?
for example
Test.ini
color = fc
color = ab
batch
Set color1 = fc (reading from ini file)
Set color2 = 0A (reading from ini file)
one last thing ... if I want to read a set of variables. ini file how can I do?
for example
Test.ini
color = fc
color = ab
batch
Set color1 = fc (reading from ini file)
Set color2 = 0A (reading from ini file)
Re: how to copy a folder by date?
walter4991 wrote:Test.ini
color = fc
color = ab
Don't use the same value for different data and be careful with white spaces (also in your batch code).
Test.ini
Code: Select all
color1=fc
color2=ab
ReadIni.bat
Code: Select all
@echo off &setlocal
for /f "delims=" %%a in (Test.ini) do set "%%a"
echo %color1%
echo %color2%
pause
Regards
aGerman
-
- Posts: 21
- Joined: 11 Dec 2010 10:17
Re: how to copy a folder by date?
sorry ... white space will not put them online is the translator that puts them ... xD (I'm Italian)
This code does not work ...
you have some other idea?
This code does not work ...
Code: Select all
@echo off &setlocal
for /f "delims=" %%a in (Test.ini) do set "%%a"
echo %color1%
echo %color2%
pause
you have some other idea?
Re: how to copy a folder by date?
Hmm, works fine for me.
Did you change the Test.ini according my example? What is the output?
BTW: Why did you translate code or the content of files?
Regards
aGerman
Did you change the Test.ini according my example? What is the output?
BTW: Why did you translate code or the content of files?
Regards
aGerman
-
- Posts: 21
- Joined: 11 Dec 2010 10:17
Re: how to copy a folder by date?
yes yes I changed it does not work not even open the DOS window.
Re: how to copy a folder by date?
Show me the content of your INI file and your batch file (both enclosed in code tags). Otherwise I'm not able to see where it fails. As I said, the example worked for me.
Regards
aGerman
Regards
aGerman
-
- Posts: 21
- Joined: 11 Dec 2010 10:17
Re: how to copy a folder by date?
code of batch:
I would write the color in a file. ini and then when it starts the batch to read and set the color written nell'file. ini ...
Code: Select all
call C:\stile.bat
set/p "cho=>>> "
if %cho%==0 goto SCELTA
if %cho%==1 goto NE-AZ
:NE-AZ
color 09
echo color 09>C:\stile.bat
cls
:BI-AZ
color f9
echo color f9>C:\stile.bat
cls
I would write the color in a file. ini and then when it starts the batch to read and set the color written nell'file. ini ...
Re: how to copy a folder by date?
Try:
Regards
aGerman
Code: Select all
@echo off &setlocal
if exist style.ini for /f "delims=" %%a in (style.ini) do set "%%a"
if not defined color (
setlocal enabledelayedexpansion
set /p "color=Enter a color combination: "
color !color!
>style.ini echo color=!color!
endlocal
) else (
color %color%
)
pause
Regards
aGerman
-
- Posts: 21
- Joined: 11 Dec 2010 10:17
Re: how to copy a folder by date?
ok wrote in ini file ... but to load the color insert before, the initiation of the batch?
Re: how to copy a folder by date?
Um, sorry ... what is the meaning of your last post
I don't get it.
Regards
aGerman
I don't get it.
Regards
aGerman