@echo off
setlocal enabledelayedexpansion

echo ======================================
echo   DEBUG MODE - Remove Dots from Folders
echo ======================================

echo Step 1: Checking current directory
echo Current dir: %cd%
echo.

echo Step 2: Listing all directories
echo All directories found:
dir /ad /b
echo.

echo Step 3: Finding directories with dots
echo Directories containing dots:
dir /ad /b | findstr "\."
echo.

echo Step 4: Starting renaming process...
echo.

for /f "tokens=*" %%d in ('dir /ad /b ^| findstr "\."') do (
    echo --------------------------------------
    echo Processing: [%%d]
    set "oldname=%%d"
    
    rem Check if folder still exists
    if exist "%%d\" (
        echo Folder exists: YES
        
        set "newname=!oldname:.=!"
        echo New name would be: [!newname!]
        
        if not exist "!newname!\" (
            echo New name doesn't exist yet: YES
            echo Command to execute: ren "%%d" "!newname!"
            
            ren "%%d" "!newname!"
            
            if exist "!newname!\" (
                echo SUCCESS: Renamed to [!newname!]
            ) else (
                echo FAILED: Rename unsuccessful
            )
        ) else (
            echo ERROR: "!newname!" already exists!
        )
    ) else (
        echo Folder doesn't exist or is no longer accessible
    )
)

echo.
echo ======================================
echo Process completed. Check results above.
pause