I have the following batch file in Windows 7 to be executed by a context menu shortcut. My aim is to move and rename a quote folder containing subfolders and files to a different path and rename it with the project number inserted when prompted.
for %%Q in (.) do set quotenumber=%%~nQ
for %%Y in (.\..) do set year=%%~nY
for %%C in (.\..\..\..) do set client=%%~nC
set /P projectnumber="Enter Project number>"
move "c:\myfiles\mainfiles\clients\%client%\quotes\%year%\%quotenumber%" "c:\myfiles\mainfiles\clients\%client%\projects\%year%\%projectnumber%"
I get the error "the process does not have access to the file because it is being used by another process". Can anybody tell me what I am doing wrong? I am not a programmer and cannot get this to work! Any help would be greatly appreciated.
Looking at your code I'm assuming that you;re executing it in c:\myfiles\mainfiles\clients\%client%\quotes\%year%\%quotenumber%
dir.
And in the last line you try to move the same dir to another place.Which is impossible because the dir is held by the script itself.Try this:
for %%Q in (.) do set quotenumber=%%~nQ
for %%Y in (.\..) do set year=%%~nY
for %%C in (.\..\..\..) do set client=%%~nC
set /P projectnumber="Enter Project number>"
cd ..
move "c:\myfiles\mainfiles\clients\%client%\quotes\%year%\%quotenumber%" "c:\myfiles\mainfiles\clients\%client%\projects\%year%\%projectnumber%"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With