0

I need to rename the folders in path2 to the folders in path1 if they have a specific file in common. They are duplicates but folders name in path2 follows the pattern [ARTIST] TITLE, and I need it to get back to it's original name.

I tried this but it doesn't change directory within the for loop, and at this point I know it doesn't make sense to even continue...

for /R %%f in (*.bms;*.bme;*.bml;*.pms;*.bmson) do (
    set Hash1 = CertUtil.exe %%f
    set Dir1 = %cd%
    
    cd C:\path2\
    for /R %%f in (*.bms;*.bme;*.bml;*.pms;*.bmson) do (
        setlocal Hash2 = CertUtil.exe %%f
        setlocal Dir2 = %cd%
        if Hash1 equ Hash2 ( 
            ren %Dir2% %Dir1%
            )
        )
    cd C:\path1\
    )
  • 1
    Also, you've written `setlocal` instead of `set` in that inner `for` loop. Also also, once you fix the spaces, you'll still run into an issue [because you need to use delayed expansion](https://stackoverflow.com/questions/9681863/windows-batch-variables-wont-set). Also (also also), you need to call the variables in that `if` statement instead of just writing their names, because right now that conditional is comparing two literal strings. – SomethingDark Oct 15 '20 at 16:23
  • 1
    Sorry, that wasn't actually a question; it's just how StackOverflow decided to write "this question is a duplicate of ____" because your current issue is absolutely caused by the fact that you put spaces around your `=`s. Spaces are significant in batch, and so you've created variables called `%Hash1 %` and `%Dir1 %` instead of `%Hash1%` and `%Dir1%`. – SomethingDark Oct 15 '20 at 16:29
  • 2
    You cannot assign the output of a command to a variable using the `SET` command. You need to use a `FOR /F` command to do that. The `IF` comparison is also incorrect as you are not expanding the values of the variable. You should take a step back and learn each command one at a time and make sure it is working before you move onto the next. – Squashman Oct 15 '20 at 16:29
  • 1
    Hmmm okay I'll redo everything then, thank you @SomethingDark and Squashman – SOUNDSPHERE BEST GAME Oct 15 '20 at 16:35

0 Answers0