Page 1 of 1

Bulk Rename Files to Parent Folder Name

PostPosted: Thu May 21, 2020 5:35 pm
by groundswell
Hi,

i have been using the gui version of bulk rename for awhile to achieve this but I am having instances where I have sometimes dozens of individual folders that I need to rename files inside them and trying to reduce the amount of clicking it requires.

Currently I have individual folders that have 1 file in each of these folders that I would like to rename as the folder name. I would appreciate any help in creating script for use with command line version. I have a screenshot below showing what I am currently doing with the gui version of bulk rename now for reference.

Image

Thanks!

Re: Bulk Rename Files to Parent Folder Name

PostPosted: Fri May 22, 2020 12:11 pm
by therube
As a start, mess around with this & see where it gets you.
(In this case, perhaps in general, command line ordering is important; i.e., the /REMOVENAME switch needs to come before [at least some of] the others...)

Code: Select all
brc32.exe  /removename  /appendfolder:P:___:1  /pattern:*.TXT  /recursive


(I stuck the underlines in there only to make changes more apparent.)

Re: Bulk Rename Files to Parent Folder Name

PostPosted: Sat May 23, 2020 5:19 am
by groundswell
Thanks for the sample code!

I ran the following command:
C:\BRC\BRC64.exe /removename /appendfolder:P::1 /pattern:*.TXT /recursive

Unfortunately it didn't rename any of the files. Below are screenshots of the results.

Image
Image

Re: Bulk Rename Files to Parent Folder Name

PostPosted: Sat May 23, 2020 7:59 am
by RegexNinja
Please note that /Pattern is case-sensitive, so you might need something like:
C:\BRC\BRC64 /Pattern:"*.txt *.TXT" /Recursive /RemoveName /NoDup /AppendFolder:P::1

That renames files like: ParentFolder, but if any folder has more than 1-file:
It starts renaming like: ParentFolder_1, ParentFolder_2, etc (they dont show that way in the preview).
Cheers.

Re: Bulk Rename Files to Parent Folder Name

PostPosted: Sat May 23, 2020 11:57 pm
by groundswell
It looks like that command will work to rename the files but it didn't actually rename the files, they still kept the original file name. Below is a screenshot of what I ran and results.

Image


Thanks!

Re: Bulk Rename Files to Parent Folder Name

PostPosted: Sun May 24, 2020 12:08 am
by RegexNinja
Once you're happy with the preview, and you're not worried about more than one file per SubFolder.
Just add /Execute to the end of your command-line, that will actually perform the renames.
Cheers!

Re: Bulk Rename Files to Parent Folder Name

PostPosted: Sun May 24, 2020 12:15 am
by groundswell
Thanks for that! Tested with the execute switch and all good now. Considered this resolved!

Thanks everyone for the help! :D

Re: Bulk Rename Files to Parent Folder Name

PostPosted: Sun May 24, 2020 4:00 am
by trm2
How do you get the screenshots in the forum?

Re: Bulk Rename Files to Parent Folder Name

PostPosted: Sun May 24, 2020 4:26 am
by groundswell
You can click the Img button when you are replying.
Image

Then you need to have the image online somewhere so you can add the URL for it between the [img} tags. I use imgur but probably any online image host will work.
Image

Re: Bulk Rename Files to Parent Folder Name

PostPosted: Sun May 24, 2020 4:43 am
by trm2
Thanks. I'll keep that in mind but I usually do not use any kind of cloud (old fashioned).

I appreciate the quick response.