Example of how to use smart naming rules to remove unwanted characters from a file name

1,116 views
Skip to first unread message

Jack Smith

unread,
Aug 21, 2023, 12:02:35 AM8/21/23
to Video DownloadHelper Q&A
tl;dr For my example, scroll down to bolded large text near bottom.

The complete absence of documentation regarding the Smart Naming feature is very frustrating. 

After having spent more time than I would have liked to searching this forum for a solution to my question of "How to remove unwanted characters (i.e. replace with an empty character) using the smart naming rules" I wanted to provide my current solution so that others don't have to spend several hours looking for a basic solution like I did.


Say that I want to download this video. I highlight the video's title which I intend to use as the video's name, right click and navigate to the VHD context menu, and open up the smart naming rules so that I am given an XPath expression for VDH to look for and use as the smart name. Now check the Advanced box.

Once you have enabled the advanced option, the xpath expression I get is:

/html/body/ytd-app/div[1]/ytd-page-manager/ytd-watch-flexy/div[5]/div[1]/div/div[2]/ytd-watch-metadata/div/div[1]/h1/yt-formatted-string

This would result in the file being named:
"Polyphia - Playing God (Official Music Video)" without the quotations.

In order to remove undesired characters from the file name, I used the translate() function within the XPath expression field.

I leave the "Regular Expression" field AS IS.

For example, if I wanted to remove the following example characters from a video's title: - & ! , ( )

The resulting XPath expressions I've used is:

translate(/html/body/ytd-app/div[1]/ytd-page-manager/ytd-watch-flexy/div[5]/div[1]/div/div[2]/ytd-watch-metadata/div/div[1]/h1/yt-formatted-string, '-&,!()', '')

Since youtube XPath expressions can be a bit...excessive... here is a simple version:

translate(VDH_Given_XPath_Expression, '-&,!()', '') 

This will replace any of the characters -*,!() in a file name with an empty character.

The VDH Given XPath expression we want to have an effect on is going to be the first value within the parentheses followed by a comma. 

The second portion of the translate function enclosed with apostrophes are the characters I'd like to remove from any file names. In this example, any of these characters: -&,!()

The last portion of the translate function is a double apostrophe (NOT quotation marks) (e.g. '') to represent the empty character I'd like to replace -&,!() with.

The file name began as:
Polyphia - Playing God (Official Music Video)

The file name result after the translate function:
Polyphia  Playing God Official Music Video

(I would lastly use Bulk Rename Utility from TGRMN software (not an ad, just my preferred tool) to replace double spaces with a single space and have much cleaner looking file names on my computer in the end.)

Hopefully this helps any curious person who lacks knowledge of XPath expressions in the future.

Jack Smith

unread,
Aug 21, 2023, 12:04:26 AM8/21/23
to Video DownloadHelper Q&A
If anyone has a solution which is more simple or one which also replaces the double space with a single space WITHOUT having to use an external application afterwards, feel free to let me know. :)
Reply all
Reply to author
Forward
0 new messages