#1 2020-05-18 17:10

nickgreenfield
Member
Registered: 2020-05-18
Posts: 3

Script to rename reverse names of folders?

Is there a pascal script that I can use, please, to reverse the names of my huge collection of folders?

For example, I have a folder called John Smith (no comma, just one space between words) and I want to rename it to Smith, John (with a comma then one space between words.

I'm not experienced enough to write a script so I'm holing someone kind will do it!

Thanks

Offline

#2 2020-05-18 20:40

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Script to rename reverse names of folders?

Hi and welcome.

FROM:
John Smith

TO:
Smith, John

Use for example the Rearrange Rule
https://www.den4b.com/wiki/ReNamer:Rules:Rearrange
(there are Examples at the end of that page)

For your issue use
Split by delimiters " " (((That will split at an space and store the parts into $1,$2,...)))
New pattern "$2, $1" (((Rearrange the matched parts and add an comma yourself)))
[x]skip extension

Note: Quote-signs are only for clarification, don't use them in the rule itself!



In the ReNamer sub-forum there are more posts about that, just search for "swap" for more ideas.


 
 


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#3 2020-05-19 13:53

nickgreenfield
Member
Registered: 2020-05-18
Posts: 3

Re: Script to rename reverse names of folders?

Thanks for that helpful reply. I have also read the forum you suggest; sadly neither are working for me.

I have a huge number of ebooks stored in folders such as "Stephen King" (without the quotes") and want to rename the to "King, Stephen" (without the quotes). I've tried your solution and also

Example 4:

Task: Switch the words, and remove the comma between them.

From:    To:
King, Stephen    Stephen King
Cook, Robin    Robin Cook

Settings:

Delimiter: ", " (without the quotes)

New Order: $2 $1

Obviously that's the opposite of what I want but the rule should be clear.

Applying that rule and your suggestion to "Stephen King.epub"

What I get is ", Stephen King.epub"

I've tried various arrangements - but I'm obviously missing something. What?

Also, this applies to files - where is the setting to apply it to folder names only (and not folder contents)?

Thank you!

Offline

#4 2020-05-19 17:22

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Script to rename reverse names of folders?

nickgreenfield wrote:

I've tried various arrangements - but I'm obviously missing something. What?

Hi, sorry, I am not sure if I understand you correctly (my bad due my bad english)
But I provided you already the solution for your renaming issue in my post above. You say that that didn't work?


nickgreenfield wrote:

Also, this applies to files - where is the setting to apply it to folder names only (and not folder contents)?

See menu Settings > Filters

The documentation is there > https://www.den4b.com/wiki/ReNamer:Filter_settings

That?


 


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#5 2020-05-20 01:43

Rnmr
Member
Registered: 2019-10-22
Posts: 37

Re: Script to rename reverse names of folders?

Try these?
  -  -  -  -

Example 1- rearrange with no comma

Single Rule- Rearrange

tick "Exact pattern of Delimeters" at top

"| |" (no quotes)

New Pattern

$2 $1

skip ext.



Example 2- rearrange with added comma

Single Rule- Rearrange

tick "Exact pattern of Delimeters" at top

"| |" (no quotes)

New Pattern

$2, $1

skip ext.



Example 3- rearrange with comma removed

Rule #1
Replace

Replace:

", " (no quotes)

With:

" " (no quotes)

Rule #2
Rearrange

tick "Exact pattern of Delimeters" at top

"| |" (no quotes)

New Pattern

$2 $1

skip ext.

Last edited by Rnmr (2020-05-20 01:47)


To be yourself in a world that is constantly trying to make you something else is the greatest accomplishment.
- RWE

Offline

#6 2020-05-20 14:42

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,367

Re: Script to rename reverse names of folders?

Question 1: How to rearrange "John Smith" to "Smith, John".

You can use the Rearrange rule or the Regular Expressions rule. There are many examples on the forum and on the wiki.

Using the Rearrange rule:
* Exact pattern of delimiters: " " (just a space character, without quotes)
* New pattern: $2, $1

Question 2: How to rename folders, rather than files.

Adjust your Filter Settings.

Enable "Add folders as files" option and disable "Add files within folders" option, and check other filter settings.

Offline

#7 2020-05-20 16:50

Rnmr
Member
Registered: 2019-10-22
Posts: 37

Re: Script to rename reverse names of folders?

Yes, you only need a space to represent the space division in this particular example.

I'm just in the habit of using pipes for spaces because they
make the spaces easier to visualize in that field and will work for
any number of words, not just the simple 2 word split.

Last edited by Rnmr (2020-05-20 16:54)


To be yourself in a world that is constantly trying to make you something else is the greatest accomplishment.
- RWE

Offline

#8 2020-05-20 17:33

nickgreenfield
Member
Registered: 2020-05-18
Posts: 3

Re: Script to rename reverse names of folders?

I have to say that I'm really impressed and so grateful for all of the swift and helpful advice on this forum. Quite rare and outstanding.

No idea why Stefan's solution wouldn't work (thanks Stefan) but this works a treat:

Example 2- rearrange with added comma

Single Rule- Rearrange

tick "Exact pattern of Delimeters" at top

"| |" (no quotes)

New Pattern

$2, $1

skip ext.

Thank you Rnmr!

I will now convert thousands of folders (I have a huge collection) in a matter of minutes.

This is a great program with multiple uses. Now that I've found it, it's certainly a keeper.

Offline

Board footer

Powered by FluxBB