So I got my answer to the
question, but as it was a duplicated issue and I am a newbie on this forum- it was closed and I am unable to ask additional question in similar topics
By using this How to create a subfolder based on current date? solution I was able to achieve what I wanted [thank you very much user compo]
And so this code is working A-OK:
@Echo Off
Set "sd=C:\Users\YOUR USER NAME\AppData\Roaming\Mozilla\Firefox\Profiles\fsj89244"
Set "dd=D:\Backup Copies\Firefox\Profile"
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
It creates a sub-folder with a date [on drive D] in its name and then copies to it all content from a specified path [from the drive C]. This speeds up my manual creation of backup copies
But if the script is executed again I would need it to check first if such sub-folder exists. And if yes then leave it alone and create a folder with name in date format >>YYYY MM DD v2<<; and the next time >>YYYY MM DD v3<< etc. which would stop happening when the date in the operating system would change to a next day
dir /ad /onwill sort the folders by name and theforends with the last version plus one (The obviousfor /d %%a in ("%ds%*") do set /a ver+=1just counts the found folders and so will be incorrect if a folder is missing for any reason and probably will use an already "occupied" folder)The first folder of a day will be in the format
YYYY MM DD, all further folders will be in the formatYYYY MM DD vX. If you want the first folder to be the same format (... v0), use justmd "%newFolder%.