2

I have folders that have specific names.

Each of these folders contains a file named preview.png

folders containing <code>preview.png</code>

Is it possible to name the preview.png exactly after the folder which contains it? So that in the example preview.png would be renamed to Basic (Green).png I tried to use the tool bulk rename utility, but didn't achieve what I wanted.

Phil
  • 94
  • 1
    In the example depicted, you have two pngs - is it only ones called "preview.png" that would be renamed? Otherwise, what would icon.png be renamed to? How deep is the folder structure? What OS are we using? – Paul Aug 02 '19 at 04:22
  • 2
    So, just rename preview.png, leave icon.png and do nothing with it. Folder structure is just one level deep, there are no subfolders and every folder only contains these two files. The OS is Windows 10, ver 1903 – Phil Aug 02 '19 at 05:23

1 Answers1

0

For command line in same folder (top-level folder tree):


cd /d "c:\folder_target\" & for /d /r %i in (*)do ren "%i\Preview.png" "%~ni.png"

For bat/cmd file:


@echo off 
cd /d "c:\folder_target\"
For /D /R %%i in (*)do ren "%%i\Preview.png" "%%~ni.png"

You can do this using For /D and /R

Io-oI
  • 8,193