|
Answer» Hi... I am trying to find a way to remove 'n' characters fro ALL files in a DOS directory. I found this on the web but it doesn't work. I am not overly familiar with DOS and CMDS so any HELP will be greatly appreciated.. MANY thanks
tried:echo off setlocal enabledelayedexpansion set FOLDER_PATH="D:\Some DOS CMDS\NEW FOLDER" for %%f in (%FOLDER_PATH%*) do if %%f neq %~nx0 ( set "filename=%%~nf" ren "%%f" "!filename:~0,-26!%%~xf" ) PAUSESometimes I can be a bit slow on the uptake, but why ELIMINATE characters from file NAMES on a mass scale? While you ponder that, this little piece of doggerel may just help.
Code: [Select]echo off setlocal enabledelayedexpansion set folder=c:\temp
for /f %%f in ('dir /b /a-d %folder%') do ( set input=%%f set output=!input:n=! ren %folder%\!input! !output! )
pause
Be sure to change the folder name in the third line.
Happy Coding
|