Page 1 of 1

rename:keep characters from start

Posted: 04 Apr 2015 07:55
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?

Re: rename:keep characters from start

Posted: 04 Apr 2015 08:03
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";

Re: rename:keep characters from start

Posted: 04 Apr 2015 08:10
by yusef88
exactly.very thanks :tup:

Re: rename:keep characters from start

Posted: 04 Jan 2023 19:03
by Theodecarvalho
I tried it with folders, with goal to merge them, but I failed it...

Re: rename:keep characters from start

Posted: 04 Jan 2023 19:44
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";

Re: rename:keep characters from start

Posted: 04 Jan 2023 19:56
by Theodecarvalho
Is there a way to merge folders that became with same name?