Multi-level renaming

Bulk Rename Utility How-To's

Multi-level renaming

Postby NolaineCrusher » Sat Dec 21, 2024 1:47 am

I'm reorganizing my audiobook library after switching to a new library management approach, and its going very slowly because I'm having to do the renaming in a series of replacements that I would love to be able to do in one fewer operations, if possible. If I were working on a faster machine, this wouldn't be such a problem, but I'm working on a remote server and file operations are very slow.

I'm renaming directories with multiple levels of subdirectories, working from the bottom up.

Some directories have a string inside square brackets with I need to get rid of, including the brackets and the whitespace in front of it. I use [

Right now my approach is:

(lowest level subdirectories)
Currently looks like:
Code: Select all
#. Text To Keep - Year {Information to Get Rid Of}

What I want it to look like
Code: Select all
##. Text to Keep (Year)


Sort by name to get all the lines of subdirectories that begin with an integer together, select all the ones have an integer < 10, and execute the following operations on all of them at once.
  • Use RegEx(1)
    Code: Select all
    \{.*\}
    to get rid of the curly brackets, the text inside the curly brackets, and the leading whitespace before the curly brackets
  • Replace(2)
    Code: Select all
    -
    with
    Code: Select all
    (
  • Add(7) Prefix 0 to pad the leading integer
  • Add(7) Suffix
    Code: Select all
    )

Then go through and select all the subdirectories without a leading integer, or with an integer >= 10, and do the same operation, but without padding the leading integer.

Then I deal with the upper level subdirectories, which only have a string in square brackets (with leading whitespace) at the end, which I get rid of using
Code: Select all
[*]
.

This is pretty much the limit of what I can do with my limited knowledge of regex. I'm wondering if there is some way to streamline it a bit more, using masks or something, but I'm not sure how?

My bottom-level subdirectory has some extra material I want to get rid of, but I don't know if it's possible to delete files using a rename operation. I know you can move them to a different location, but not sure about deleting? (I have considered moving them to a temporary directory and discarding them.) But I'd basically need to locate them by their file extension (or sort the list by file type) to do that. So that's another operation I have to do (actually five different operations, as there are five different file types I have to delete, and each time it takes upwards of 10 minutes to locate, select, and delete 200-400 very small simple text files.

Thank you for any help you can provide.
NolaineCrusher
 
Posts: 1
Joined: Sat Dec 21, 2024 12:53 am

Return to How-To