@echo off
cd /d c:\Downloads
for /f "delims=" %%a in ('dir /ad /b') do call :process "%%a"
goto :eof
:process
set folder=%1
echo Reading %folder%
for /f "delims=" %%f in ('dir %folder% /b') do ECHO ren %folder% "%%f"
@echo off
for /f "tokens=* delims=" %%a in ('dir /ad /b') do call :process "%%a"
goto :eof
:process
set folder=%1
echo Reading %folder%
for /f "delims=" %%f in ('dir %folder% /b') do ECHO ren "%folder:~1,-1%\%%f" "%folder:~1,-1%"
ASKER
for %N in ("%CD%") do ren *.* "%~nN.*"
or you could build a small BAT file as:@echo off
pushd c:\basedir && (
for %%N in ("%CD%") do ren *.* "%%~nN.*"
popd
)
~bp
ASKER
ASKER
@echo off
call :RenameFile "c:\temp\Sample Nova 2011-09-28\sample-nova.2011-09-28.xls"
exit /b
:RenameFile [file-path]
if exist "%~1" (
for %%A in ("%~1") do (
for %%B in ("%%~dpA.") do (
ren "%~1" "%%~nB%%~xA"
)
)
)
exit /b
~bp
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
VBScript (Visual Basic Scripting Edition) is an interpreted scripting language developed by Microsoft that is modeled on Visual Basic, but with some important differences. VBScript is commonly used for automating administrative and other tasks in Windows operating systems (by means of the Windows Script Host) and for server-side scripting in ASP web applications. It is also used for client-side scripting in Internet Explorer, specifically in intranet web applications.
TRUSTED BY
See the example here, where I create a file, and then immediately try to create a folder by the same name: (this is on Win7)