Rename sub-file to same name as parent folder

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
JTCGiants56
Posts: 192
Joined: Fri Nov 28, 2014 3:58 pm

Rename sub-file to same name as parent folder

Post by JTCGiants56 »

Hello, so I'm not entirely sure everything can do this, but figured i'd ask.

Basically I have the below command. Which finds folders that contain "-ktr" and has 1 file that contains "-ktr". The folder and file names are usually slightly different. I'm wondering if there is a way to mass rename all of the files in these folders to match that of their parent folder?

Code: Select all

-ktr child:-ktr childfilecount:1 childfoldercount:0
Thanks in advance.
void
Developer
Posts: 16748
Joined: Fri Oct 16, 2009 11:31 pm

Re: Rename sub-file to same name as parent folder

Post by void »

You would need to search for all the files, please try the following search:
file: -ktr -ktr\
  • Select all the results
  • From the Edit menu, under the Advanced submenu, click Advanced Move to folder...
  • Check Regex.
  • Change Old format to:
    ^(.*?)\\([^\\]*)\\([^\\]*)(\.[^\\]*)$
  • Change New format to:
    \1\\\2\\\2\4
  • Double check the new full paths look OK, and click OK.
Each group of ( and ) captures part of the filename, \1 is used to recall the first capture, \2 the second and so on.
The first group is the path
The second, the parent folder
The third is the filename (which we discard)
and the fourth is the extension.

With the new format, we rebuild the filename by using the path \\ parent folder \\ parent folder . extension
JTCGiants56
Posts: 192
Joined: Fri Nov 28, 2014 3:58 pm

Re: Rename sub-file to same name as parent folder

Post by JTCGiants56 »

void wrote: Sun Mar 24, 2019 4:03 am You would need to search for all the files, please try the following search:
file: -ktr -ktr\
  • Select all the results
  • From the Edit menu, under the Advanced submenu, click Advanced Move to folder...
  • Check Regex.
  • Change Old format to:
    ^(.*?)\\([^\\]*)\\([^\\]*)(\.[^\\]*)$
  • Change New format to:
    \1\\\2\\\2\4
  • Double check the new full paths look OK, and click OK.
Each group of ( and ) captures part of the filename, \1 is used to recall the first capture, \2 the second and so on.
The first group is the path
The second, the parent folder
The third is the filename (which we discard)
and the fourth is the extension.

With the new format, we rebuild the filename by using the path \\ parent folder \\ parent folder . extension
Wow thanks, going to try this out. Have one other question. How would I mass rename and remove a single word from a bunch of files, where the word exists in different spots? It's easy to do this if the word is at the beginning or end, but I'm not sure how to do this if it is in different spots. Thanks for your help.
therube
Posts: 4977
Joined: Thu Sep 03, 2009 6:48 pm

Re: Rename sub-file to same name as parent folder

Post by therube »

Remove a string, 'test', from file names:

Code: Select all

tester
testexcept-flashallow-simple.pset
TestExampleGen.webidl
APZCTreeManagerTester.h
bug344830_testembed.svg
nsILayoutRegressionTester.idl
sigslottester.h.pump
pytester.py
TestEncoding.cpp
Old Name: (.*)test(.*)
New Name: \1\2

Code: Select all

er
except-flashallow-simple.pset
ExampleGen.webidl
APZCTreeManagerer.h
bug344830_embed.svg
nsILayoutRegressioner.idl
sigsloter.h.pump
pyer.py
Encoding.cpp
(For something like this, I'd probably use an actual file rename program, even though Everything Rename is an actual rename program. [And only because an errant OK...])
JTCGiants56
Posts: 192
Joined: Fri Nov 28, 2014 3:58 pm

Re: Rename sub-file to same name as parent folder

Post by JTCGiants56 »

therube wrote: Sun Mar 24, 2019 11:50 am Remove a string, 'test', from file names:

Code: Select all

tester
testexcept-flashallow-simple.pset
TestExampleGen.webidl
APZCTreeManagerTester.h
bug344830_testembed.svg
nsILayoutRegressionTester.idl
sigslottester.h.pump
pytester.py
TestEncoding.cpp
Old Name: (.*)test(.*)
New Name: \1\2

Code: Select all

er
except-flashallow-simple.pset
ExampleGen.webidl
APZCTreeManagerer.h
bug344830_embed.svg
nsILayoutRegressioner.idl
sigsloter.h.pump
pyer.py
Encoding.cpp
(For something like this, I'd probably use an actual file rename program, even though Everything Rename is an actual rename program. [And only because an errant OK...])
Thank you. I normally use the bulk rename tool, but I have yet to find a way to mass rename files located all over a computer across multiple drives.
JTCGiants56
Posts: 192
Joined: Fri Nov 28, 2014 3:58 pm

Re: Rename sub-file to same name as parent folder

Post by JTCGiants56 »

Apologies, one last question.

How would I then search for all folders where the file name matched the folder name (with the same 1 childfilecount and -0 childfoldercount below)

Code: Select all

-ktr child:-ktr childfilecount:1 childfoldercount:0 
void
Developer
Posts: 16748
Joined: Fri Oct 16, 2009 11:31 pm

Re: Rename sub-file to same name as parent folder

Post by void »

The following search may help:
regex:^.*\\([^\\]*)\\\1(\.[^\\]*)?$

This will list files with the same base name as the parent folder.

Add -ktr to limit the results to just files with -ktr, eg:
-ktr regex:^.*\\([^\\]*)\\\1(\.[^\\]*)?$

Or if your trying to find -ktr files that don't match the parent folder:
-ktr !regex:^.*\\([^\\]*)\\\1(\.[^\\]*)?$
therube
Posts: 4977
Joined: Thu Sep 03, 2009 6:48 pm

Re: Rename sub-file to same name as parent folder

Post by therube »

I use BRU (& Advanced Renamer).
With BRU I virtually always drag files from Everything into BRU.
(BRU can be buggy in its drag&drop so it might take more then 1 attempt before the files show up.)

(AR, I've set up as a SendTo & either use that or again d&d from Everything.)
JTCGiants56
Posts: 192
Joined: Fri Nov 28, 2014 3:58 pm

Re: Rename sub-file to same name as parent folder

Post by JTCGiants56 »

Thanks for the tips all. Will try this out.
JTCGiants56
Posts: 192
Joined: Fri Nov 28, 2014 3:58 pm

Re: Rename sub-file to same name as parent folder

Post by JTCGiants56 »

therube wrote: Mon Mar 25, 2019 11:23 am I use BRU (& Advanced Renamer).
With BRU I virtually always drag files from Everything into BRU.
(BRU can be buggy in its drag&drop so it might take more then 1 attempt before the files show up.)

(AR, I've set up as a SendTo & either use that or again d&d from Everything.)
You weren't kidding. The drag and drop is awefully inconsistant. Was working great at first. Dragged 50+ files with no issue. Then after a rename it no longer accepts drops. Restarted everything, BRU, explorer. Nothing now.
therube
Posts: 4977
Joined: Thu Sep 03, 2009 6:48 pm

Re: Rename sub-file to same name as parent folder

Post by therube »

Then after a rename it no longer accepts drops. Restarted everything, BRU, explorer. Nothing now.
I haven't seen that happen.

I might have caught (& don't really want to try ;-)), that if a particular file (drive) is offline & you drag that file into BRU, it crashes (Windows) Explorer.


Ordinarily what I see with d&d, is that not all of the dragged files actually end up displaying in BRU.
Like if I drag 9 files (or 90 or 900...), maybe only a few actually display.
I clear the BRU list, then drag again, & with that, in most cases, all 9 show up.

Also BRU's count (on its' "taskbar" is typically incorrect too).
Post Reply