1

I am making a cleanup tool that will delete and rename some specified directories and files. I can individually rename and delete directories and files, but I cannot rename more than one folder, and I cannot rename files within sub-directories. Here is my script:

if not exist Plugin mkdir Plugin
RENAME "xml" "XML"

RENAME "x64\bin.exe" "x64\bin_x64.exe"
RENAME "x64" "64bit"

RENAME "x86\bin.exe" "x86\bin_x86.exe"
RENAME "x86" "32bit"

rmdir Licenses /s /q
del bin_old.exe
del bin.exe.bak
del README.md
del license.txt
del components.xml
del InstallationLog.txt
del maintenancetool.dat
del maintenancetool.exe
del maintenancetool.ini
del maintenancetool.zip
del network.xml

As you can see, I want to rename the 32bit executable within the x86 directory to bin_x86.exe, then to rename it's containing folder from x86 to 32bit, and then the same equivalent for the 64bit binary and directory. Currently my script can successfully rename the first defined folder (but not it's binary), and not the second folder or binary.

2
  • 1
    You have some typos there - "RANAME"
    – paradroid
    Mar 8, 2018 at 2:18
  • Oops, thanks for spotting that. My script doesn't actually contain the typo, so it isn't affecting the results... Mar 8, 2018 at 2:20

1 Answer 1

1

The RENAME command cannot work within subdirectories, so the easy solution would be to cd into the directories within the batch script before renaming the files.

cd x64
RENAME "bin.exe" "bin_x64.exe"
cd ..
RENAME "x64" "64bit"
cd x86
RENAME "bin.exe" "bin_x86.exe"
cd ..
RENAME "x86" "32bit"
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .