Rename the pdf file inside sub-directories to the name of the sub directory -


i using win 7 platform. need create bat file simplifies job. folders , files arranged in structure.

file1

  • folder1 ->abcd.pdf
  • folder2 ->shhd.pdf.............................. foldern ->gfdfgd.pdf

file2

  • folder1 ->gbg.pdf
  • folder2 ->kjc67z.pdf.............................. foldern ->iuxz4i.pdf

--

--

--

filen

  • folder1 ->ah455.pdf
  • folder2 ->jfhd45.pdf.............................. foldern ->juvxzr.pdf

i want generate batch file renames pdf file name of folder contains. example, in above structure "abcd.pdf" renamed folder1.pdf. respectively done pdf files.

also folder named "test" created inside each directory(file1,file2..etc) contains renamed pdf files of respective directory.

if copy folders inside file1 myfolder & run bat file, folder named test created , pdf file renamed , copied test folder.

but want is, want run bat file in h:\ drive. lets assume h:\ drive contains directories file1, file2....filen each directory containing sub-directory had shown in above structure. if run bat file in h:\ drive, folder named test has created inside each directory contains renamed pdf files of respective sub-directories.

@echo off &setlocal /f "delims=" %%a in ('dir /b /s /a-d *.pdf') (      set "fname=%%~fa"      %%b in ("%%~dpa.") set "nname=%%~nxb"      setlocal enabledelayedexpansion      echo ren "!fname!" "!nname!.pdf"      endlocal ) 

note: can rename 1 pdf/folder.


some other code op:

@echo off &setlocal mkdir "h:\myfolder\test" /f "delims=" %%i in ('dir /b /a-d "h:\myfolder"') (     echo %%i     cd "h:\myfolder\%%~i"     ren *.pdf "%%~nxi.pdf"     copy *.pdf "h:\myfolder\test"     cd h:\myfolder ) cd h:\myfolder\test del h:\myfolder\test\test.pdf  

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -