I want to rename file1 to file2 using a batch file in Windows 7 but with no luck.
Below is the batch file:
@echo off
c:
cd\test
ren file1 file2Error message I get is
syntax error.Update to my question: However, to be more specific, the following is the content of my script named update.cmd which I will run as administrator in Windows 7.
Here it is:
:START
cls
cd C:\Program Files\Autodesk\Revit Structure 2012\Program
ren C:RevitMFC.dll RevitMFC_dll.bakWhen I cross check the program lines above using cmd.exe run as administrator, I found out the error msg is "access is denied".
Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Ben>cd c:\program files\autodesk\revit structure 2012\program
c:\Program Files\Autodesk\Revit Structure 2012\Program>ren c:revitmfc.dll revitm fc_dll.bak Access is denied.
c:\Program Files\Autodesk\Revit Structure 2012\Program>My question: How do I overcome this "Access is denied" ?
113 Answers
If
ren file1 file2gives a syntax error, there are most certainly spaces in the files' names.
Try this instead:
ren "file1" "file2" 1 There should not be a \ after the CD command.
Try this:
@echo off
c:
cd test
ren file1 file2 5 You are likely getting the "Access Denied" error because the file or folder is read only. The other possibility is the file is in use.
You can check the file attributes as follows. To check the folder's attributes leave out the file name.
attrib [[Drive:][Path] FileName]Here is more info on how to use the attrib command.
In order to rename the file with your batch file, you will need to modify the attributes of the file, and possibly the folder. After renaming the file change the attributes back.
Word of warning; changing the name of a dynamic link library (dll) file can cause the program(s) it is associated with to stop working.
1