rename:keep characters from start

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

rename:keep characters from start

Post by yusef88 »

Code: Select all

"Remove characters from start" $n = input("Number of characters to remove:");
  rename r, "^(.{$n})(.+) > $2", "p";
hi, the above command removes the characters but how about keeping them?

highend
Posts: 14613
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: rename:keep characters from start

Post by highend »

So you want to keep $n characters and remove the rest?

Code: Select all

    $n = input("Number of characters to keep:");
    rename r, "^(.{$n})(.*(?=\.))(.+) > $1$3", "p";
One of my scripts helped you out? Please donate via Paypal

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: rename:keep characters from start

Post by yusef88 »

exactly.very thanks :tup:
Attachments
2015-04-04_080722.png
2015-04-04_080722.png (56.36 KiB) Viewed 726 times

Theodecarvalho
Posts: 49
Joined: 17 Jul 2022 11:59

Re: rename:keep characters from start

Post by Theodecarvalho »

I tried it with folders, with goal to merge them, but I failed it...

highend
Posts: 14613
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: rename:keep characters from start

Post by highend »

Because the pattern above is for files, not folders...

Code: Select all

    $n = input("Number of characters to keep:");
    rename r, "^(.{$n})(.*) > $1", "p";
One of my scripts helped you out? Please donate via Paypal

Theodecarvalho
Posts: 49
Joined: 17 Jul 2022 11:59

Re: rename:keep characters from start

Post by Theodecarvalho »

Is there a way to merge folders that became with same name?

Post Reply