Batch rename with autonumber that starts with a user input interger

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
evangelina
Posts: 13
Joined: 16 Dec 2021 10:52

Batch rename with autonumber that starts with a user input interger

Post by evangelina »

Hi all, I know that I can batch rename with something like "*-<#001>"

I want to write a script that batch rename the selected file in this format "<date yyyy-mm-dd-<#00n>", while the n is an interger from user input. Can you help me with this simple script?

Thank you!

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Batch rename with autonumber that starts with a user input interger

Post by highend »

Code: Select all

    $date = <date yyyy-mm-dd>;
    $i    = input("Enter the start number incl. leading zeros!", , "001");
    $len  = strlen($i);
    foreach($item, <get SelectedItemsNames>, <crlf>, "e") {
        $num = format($i, strrepeat("0", $len));
        renameitem($date . "-" . $num, $item);
        $i++;
    }
One of my scripts helped you out? Please donate via Paypal

jupe
Posts: 2757
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Batch rename with autonumber that starts with a user input interger

Post by jupe »

rename , '<date yyyy-mm-dd>-<#00' . input("Enter the start number",, 1) . '>';

evangelina
Posts: 13
Joined: 16 Dec 2021 10:52

Re: Batch rename with autonumber that starts with a user input interger

Post by evangelina »

Thank you both! Both codes work perfectly!

Post Reply