New
#1
How to create a current date folder using batch file?
Hi
I am using following batch file for cleaning the desktop and also for taking backup of desktop:
@echo off
set curr_date=%DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2%
mkdir "%USERPROFILE%\My Documents\backup\%curr_date%_backup"
xcopy "%USERPROFILE%\Desktop" "%USERPROFILE%\My Documents\backup\%curr_date%_backup" /D/S/H/V/C/F/K/Y
for /d /r "%USERPROFILE%\Desktop" %%x in (*) do rd /s /q "%%x"
for /r "%USERPROFILE%\Desktop" %%x in (*) do del /f "%%x"
copy "%USERPROFILE%\My Documents\backup\%curr_date%_backup\*.lnk" "%USERPROFILE%\Desktop\"
del /q "%USERPROFILE%\My Documents\backup\%curr_date%_backup\*.lnk"
In the first line I am creating a folder with current date, e.g. curr_date_backup. Second, copying the contents of Desktop to the newly created folder. Third, deleting directories from the desktop. Forth, deleting files from the desktop. fifth, Copy back all the shortcuts to the desktop. sixth, deleting all the shortcuts from Current date folder.
This batch file is working perfectly in Windows XP. It works in win 7 also but the problem is that the name of the current date folder created by first command is "Desktop". when I use command prompt to check the name, the name is correct. I checked the properties of the folder the correct is there also. But in windows the name doesn't match with the expected one.
I need help. Kindly tell me what's going on? why window 7 is showing directory name as "Desktop"? Is there any other way for creating folder in win7 using batch file.
thanks