| 
                                   
Answer»  Hi,
  If you can see in the lines below I am trying to rename all the txt files to the foldername.
  exampel: this is now: c:/test/a123/test.txt c:/test/b123/test.txt c:/test/a b (2009)/test.txt
  and it should be: c:/test/a123/a123.txt c:/test/b123/b123.txt c:/test/a b (2009)/a b (2009).txt
  hours of searching and this is the closest thing I've got, only I can't figur out what I've to type with the FOLDERNAME.txt below:
  -----------------
  echo off
  for /f "delims==" %%b in ('dir /b /s /on  *.txt') do rename "%%~b" "FOLDERNAME.txt" & echo %%~b 
  pause
  -----------------
  I hope SOMEONE can help me because I am trying to fix this from yesterday.
  Kris
Code: [Select]echo off set thisdir="%cd%" for /f "delims==" %%A in ('dir /b /s /ad') do if exist "%%A\*.txt" cd %%A & for %%B in (*.txt) do ren "%%~dpnxB" "%%~nA.txt" cd %thisdir% Hi,
  Thank you this is what I was LOOKING for!
  It works    
QUOTE from: squab on FEBRUARY 20, 2010, 07:10:53 AM It works    
  
 I know it works...
  Glad to help.
 
 
  
                                 |