This is my first post this forum and I am just just a small time code tweaker- thus I need help
I want to be able to simply execute a BAT file residing in any folder in order to copy whole content of the folder containing [e.g.] my Firefox profiles to another drive. But I also need following copies created in the same day to be distinguishable with something like "V02","V03", "V04" etc. added to the end of their names if I execute such BAT file for the 2nd, 3rd, 4th etc. time. So if I will execute that BAT all in all 7 times over the course of 3 days, I need the folders with backups to present themselves like this:
2022 08 01
2022 08 01 V02
2022 08 01 V03
2022 08 01 V04
2022 08 01 V05
2022 08 02
2022 08 02 V02
2022 08 03
Alternatively they can look like this:
2022 08 01
2022 08 01 09.00.00
2022 08 01 12.30.05
2022 08 01 19.22.17
2022 08 01 23.11.56
2022 08 02
2022 08 02 00.25.43
2022 08 03
i.e. utilize time
But in both cases, as it is shown above, I would need the first copy to not have such an addition / marker. And so it [i.e. "V01" or time] would either have to not be added / created in the first place - or - in case if there is no other way, it would have to be somehow automatically removed by renaming such lonely folder [i.e. a folder that has a unique date because there are no other folders present with such date in the main folder holding those backups]
All I have now is something like this
Code: Select all
@Echo Off
Set "sd="C:\Users\YOUR-USER-NAME\AppData\Roaming\Mozilla\Firefox\Profiles"
Set "dd="Z:\Backup Copies\Firefox\Profiles""
Set "ds="
If Not Exist "%sd%\" Exit /B
For /F "Tokens=1-3Delims=/ " %%A In ('RoboCopy/NJH /L "\|" Null'
) Do If Not Defined ds Set "ds=%%A %%B %%C"
If Not Defined ds Exit /B
RoboCopy "%sd%" "%dd%\%ds%" /E
Code: Select all
Set "ds="
For /F "Tokens=1-3Delims=/ " %%A In ('RoboCopy/NJH /L "\|" Null'
) Do If Not Defined ds Set "ds=%%A %%B %%C"
If Not Defined ds Exit /B
set ver=0
for /f "tokens=3,4 delims=v " %%a in ('dir /ad /on /b "%ds%*"') do set /a ver=%%b+1
set "newFolder=%ds% v%ver%"
md "%newFolder: v0=%"