Rename content of folders to a file name in the folder

Advanced Renamer forum
#1 : 20/01-18 18:54
Kasper
Kasper
Posts: 1
I have tried myself for hours now.
I have a ton of folders called CLV-*** (*** is random letters)
In those folders i have a .nes , a .png file and a .desktop file
I want to change the names of the .png and .desktop files so they match the .nes file
I have tried with reg ex
Searching for
(.*)\.desktop (this works)
replace with
(.*)\.nes.desktop (This does not work, it will just write (.*)\.nes.desktop)
I am new to reg exp so i'm probably doing something wrong.
I have 1400 some folders, so i can't just do one folder at a time that'd take for ages.
Hope anyone can help me. :)
also tried to search for
(.*)\.
replace with
(.*)\.nes.
I could use dir name, if there was any way to copy contents of folder into a new folder and name that folder whatever .nes file is called. But i don't know how to do that without copying everything into their own folder instead of pairing up.

Edit: I actually don't need the .desktop file
just need to rename the png file to the same as the .nes file


20/01-18 18:54 - edited 20/01-18 19:17
#2 : 01/02-18 08:07
Brian Hanlon
Brian Hanlon
Posts: 29
Although this does NOT use AR, it WILL do your job:
Copy between the rows of === and Paste into a .bat file.

========================================
@echo off
:: Execute this batch from the root folder
:: which holds all the CLV-*** folders
:: I assume only one each type of file in each folder
FOR /R %%D IN (.) DO (
PUSHD %%D
setlocal enabledelayedexpansion
for /F "delims=" %%A in ('dir /b *.nes') do (
set base="%%~nA"
echo %%~pA
ren *.png !base!.png
ren *.desktop !base!.desktop
)
endlocal
POPD
)
========================================

Test Results:
(I have inserted extra spacing for clarity.)

Test folders/files BEFOREHAND:
(Different filenames)

C:\TESTING\CLV-here
C:\TESTING\CLV-name
C:\TESTING\CLV-test
C:\TESTING\CLV-yeti
C:\TESTING\CLV-zulu
C:\TESTING\FIX_NAMES.bat

C:\TESTING\CLV-here\MESSED-UP-here.desktop
C:\TESTING\CLV-here\MIXED-UP-here.png
C:\TESTING\CLV-here\WHO.nes

C:\TESTING\CLV-name\MESSED-UP-name.desktop
C:\TESTING\CLV-name\MIXED-UP-name.png
C:\TESTING\CLV-name\WHAT.nes

C:\TESTING\CLV-test\MESSED-UP-test.desktop
C:\TESTING\CLV-test\MIXED-UP-test.png
C:\TESTING\CLV-test\WHICH.nes

C:\TESTING\CLV-yeti\MESSED-UP-yeti.desktop
C:\TESTING\CLV-yeti\MIXED-UP-yeti.png
C:\TESTING\CLV-yeti\WHEN.nes

C:\TESTING\CLV-zulu\MESSED-UP-zulu.desktop
C:\TESTING\CLV-zulu\MIXED-UP-zulu.png
C:\TESTING\CLV-zulu\WHERE.nes

RUN the batchfile:

C:\TESTING>FIX_NAMES.bat
File Not Found <<== This verifies that you are in the root, NOT inside a CLV-xxxx Folder!
\TESTING\CLV-here\
\TESTING\CLV-name\ <<== These are just to let you know
\TESTING\CLV-test\ which folder is being processed.
\TESTING\CLV-yeti\ if you don't need this output,
\TESTING\CLV-zulu\ remove the 'echo %%~pA' line from the Batchfile.

Test folders/files AFTER PROCESSING:

C:\TESTING>DIR /S /B
C:\TESTING\CLV-here
C:\TESTING\CLV-name
C:\TESTING\CLV-test
C:\TESTING\CLV-yeti
C:\TESTING\CLV-zulu
C:\TESTING\FIX_NAMES.bat

C:\TESTING\CLV-here\WHO.desktop
C:\TESTING\CLV-here\WHO.nes
C:\TESTING\CLV-here\WHO.png

C:\TESTING\CLV-name\WHAT.desktop
C:\TESTING\CLV-name\WHAT.nes
C:\TESTING\CLV-name\WHAT.png

C:\TESTING\CLV-test\WHICH.desktop
C:\TESTING\CLV-test\WHICH.nes
C:\TESTING\CLV-test\WHICH.png

C:\TESTING\CLV-yeti\WHEN.desktop
C:\TESTING\CLV-yeti\WHEN.nes
C:\TESTING\CLV-yeti\WHEN.png

C:\TESTING\CLV-zulu\WHERE.desktop
C:\TESTING\CLV-zulu\WHERE.nes
C:\TESTING\CLV-zulu\WHERE.png

Which is, I think, the results that you are asking for.

It is a long post, but I think that it answers the question properly.

Hope it helps,
Brian.

----------
If this brilliant little tool has saved you time, or helped get your files in a better order, or just cleaned-up the crazy names from downloaded files, maybe you could donate a Dollar or Ten to Kim?
See https://www.advancedrenamer.com/download


01/02-18 08:07