We are re doing a folder structure on our main server for storage. But we want to simplify the process as much as possible for the graphics design team that's going to use it. So I am writing a bunch of scripts and this specific script needs to create a new folder for the year specified, rename the previous years fold and the the oldest year folder needs to be moved to Archive & renamed.
@ECHO OFF
SET /P nyear=Enter Year:
SET /A myear =%nyear%-1
SET /A ayear =%nyear%-2
mkdir "2. "%nyear%
rename "2. "%myear% "3. "%myear%
move "3. "%ayear% %cd%\Archive\
rename %cd%\Archive\"3. "%ayear% %ayear%
SET RootDir=%cd%\2. %nyear%
echo %RootDir%
SET SubA="1. January","2. February","3. March","4. April","5. May","6. June", "7. July", "8. August" "9. September", "10. October", "11. November", "12. December"
SET SubB="1. Campaigns","2. Ads","3. Internal","4. Facebook","5. Instagram"
FOR %%A IN (%SubA%) DO FOR %%B IN (%SubB%) DO IF NOT EXIST "%RootDir%\%%~A\%%~B" MD "%RootDir%\%%~A\%%~B"
EXIT
I have tested the individual parts of the script and they work fine but when it runs as a whole I get the following error:
The process cannot access the file because it is being used by another process.
Any help would be appreciated.