Help with Rename Script – Capitalize All Words (incl. A, An, The, Of etc)

Discuss and share scripts and script files...
Post Reply
shuklaharshit75
Posts: 42
Joined: 10 Aug 2024 10:12

Help with Rename Script – Capitalize All Words (incl. A, An, The, Of etc)

Post by shuklaharshit75 »

Replace all unwanted characters (- . _ [ ] ( ) % , \ * ~ >`) with a single space.

Collapse multiple spaces into one.

Trim leading/trailing spaces.

Capitalize the first letter of every word, including single-letter words like “A”.

Always lowercase the extension.

What I have tried:

Code: Select all

rename s, "-._[]()%,`*~> ", , , 8; rename r, "\s+ >  ", , , 8;; rename r, "\s+(\.[^.]+?$|$) > $1", , , 8; #139; #128; #126; #113;
I already have a partially working script that cleans up filenames and lowercases extensions. However, words like “a”, “an”, “the”, and “of” are automatically lowercased.



Original:

Code: Select all

_a an the of ..--___.txt
Current Result:

Code: Select all

A an the Of.txt
Desired Result:

Code: Select all

A An The Of.txt
Thanks in advance.

Horst
Posts: 1340
Joined: 24 Jan 2021 12:27
Location: Germany

Re: Help with Rename Script – Capitalize All Words (incl. A, An, The, Of etc)

Post by Horst »

What about all the options under
File / Rename Special >
Windows 11 Home, Version 25H2 (OS Build 26200.7171)
Portable x64 XYplorer (Actual version, including betas)
Display settings 1920 x 1080 Scale 100%
Everything 1.5.0.1402a (x64), Everything Toolbar 2.1.0, Listary Pro 6.3.6.99

shuklaharshit75
Posts: 42
Joined: 10 Aug 2024 10:12

Re: Help with Rename Script – Capitalize All Words (incl. A, An, The, Of etc)

Post by shuklaharshit75 »

Rename special #126 doesn't work.
AAAAAAAA.gif
AAAAAAAA.gif (436.43 KiB) Viewed 3092 times
I already have a partially working script that cleans up filenames and lowercases extensions. However, words like “a”, “an”, “the”, and “of” are automatically lowercased.

Code: Select all

rename s, "-._[]()%,`*~> ", , , 8; rename r, "\s+ >  ", , , 8;; rename r, "\s+(\.[^.]+?$|$) > $1", , , 8; #139; #128; #126; #113;

shuklaharshit75
Posts: 42
Joined: 10 Aug 2024 10:12

Re: Help with Rename Script – Capitalize All Words (incl. A, An, The, Of etc)

Post by shuklaharshit75 »

found a workaround solution. How to Implement True Title Case Formatting in XYplorer

1️⃣ **Locate XYplorer.ini**: Open XYplorer and navigate to **File | Save Settings** to ensure the necessary key exists in the XYplorer.ini file.

2️⃣ **Open Configuration File**: Go to **Tools | Open Configuration File...** to open the XYplorer.ini file in your default text editor.

3️⃣ **Edit the Key**: In the text editor, find the key you want to edit, such as `RenameTitleCaseExceptions=`. Make sure to edit its value rather than creating a new key.

4️⃣ **Example of Editing**: For instance, if the original line is `SettingsWarnReadonly=0`, change it to `SettingsWarnReadonly=1`.

5️⃣ **Save Changes**: After making the necessary edits, save the file in your text editor.


6️⃣ **Restart XYplorer**: In XYplorer, click **File | Restart without Saving** to apply the changes made to the ini file.

7️⃣ **Confirm Tweaks**: The changes should now take effect, allowing XYplorer to utilize the tweaked settings.



working script((Custom Events=>Clicking On Items Middle Click On File))=

Code: Select all

rename s, "-._[]()%,`*~> ", , , 8; rename r, "\s+ >  ", , , 8; rename r, "\s+(\.[^.]+?$|$) > $1", , , 8; #139; #126; #113;


Step-by-Step Explanation
1️⃣ Remove Unwanted Characters:

Command: rename s, "-._[]()%,*~> ", , , 8;`
Explanation: This command removes specific unwanted characters from file names, including -, ., _, [, ], (, ), %, ,, `, *, and ~. The operation is limited to a maximum of 8 files at a time.
2️⃣ Replace Multiple Spaces:

Command: rename r, "\s+ > ", , , 8;
Explanation: This command replaces multiple consecutive spaces in file names with a single space. The regular expression \s+ matches one or more whitespace characters.
3️⃣ Handle Spaces Before File Extensions:

Command: rename r, "\s+(\.[^.]+?$|$) > $1", , , 8;
Explanation: This command ensures that there are no unnecessary spaces before file extensions or at the end of the file name. It matches spaces followed by a file extension or the end of the string.
4️⃣ Special Rename Operations:

Commands: #139; #126; #113;
Explanation: These commands refer to specific predefined renaming operations in XYplorer:
#139: Remove diacritics from file names.
#126: Change file names to Title Case (e.g., "AAA AA.AAA" to "Aaa Aa.aaa").
#113: Copy the base name(s) of the selected item(s) to the clipboard (Shift+F).
5️⃣ Additional Rename Operations:

Commands: #128, #129, #130, #136
Explanation: These commands perform various renaming tasks:
#128: Convert spaces in file names to underscores.
#130: Convert underscores in file names back to spaces.
#136: Rename files with a specific extension (e.g., *.aaa).
Attachments
Screenshot 2025-08-23 160942.png
Screenshot 2025-08-23 160942.png (52.82 KiB) Viewed 2980 times

Post Reply