Change Is Inevitable
  • Home
  • MySQL
    • MySQL-Articles
    • AWS RDS
    • Percona Xtradb Cluster
    • MariaDB
    • Galera Cluster
    • ProxySQL
    • MySQL-Scripts
    • MySQL tools
    • MySQL Resources
  • Tools
    • MySQL Advisor
    • MySQL Random Data Generator
    • Postgresql Random Data Generator
    • Clean Prompt
  • General
    • binary-to-decimal
    • Fermat’s Theorem
    • Review
    • Just for fun
    • Personal
  • Contact Me
    • Copyright
    • MySQL Podcast (Youtube)
    • MySQL Podcast (Spotify)
Recent Posts
  • MySQL INSTANT DDL breaks EXCHANGE PARTITION
  • How to setup and use Percona Binlog Server (PBS)
  • MySQL Major Version Upgrade Checklist – how to
  • InnoDB Flushing is simple – explained
  • MySQL Tools for Performance Tuning and Test Data Generation
Recent Comments
  • Kedar on MySQL INSTANT DDL breaks EXCHANGE PARTITION
  • Jean-François Gagné on MySQL INSTANT DDL breaks EXCHANGE PARTITION
  • Reggie on A Unique Foreign Key issue in MySQL 8.4
  • Kedar on How to fix write latency in MySQL 8.4 Upgrade
  • Kedar on How to fix write latency in MySQL 8.4 Upgrade
Home » script
Change Is Inevitable

Kedar Vaijanapurkar's Blog for MySQL, technology and various subjects

  • Home
  • MySQL
    • MySQL-Articles
    • AWS RDS
    • Percona Xtradb Cluster
    • MariaDB
    • Galera Cluster
    • ProxySQL
    • MySQL-Scripts
    • MySQL tools
    • MySQL Resources
  • Tools
    • MySQL Advisor
    • MySQL Random Data Generator
    • Postgresql Random Data Generator
    • Clean Prompt
  • General
    • binary-to-decimal
    • Fermat’s Theorem
    • Review
    • Just for fun
    • Personal
  • Contact Me
    • Copyright
    • MySQL Podcast (Youtube)
    • MySQL Podcast (Spotify)

Browsing Tag

script

2 posts

10 useful shell script code snippets | Linux

  • Kedar
  • March 10, 2015
10+ useful code snippets of Linux shell scripts for how-to color, sendmail, log, change dir, parse parameters, loop, configuration file, switch..case and more.
View Post

batch script to add remove prefix zero pad bulk file rename

  • Kedar
  • March 18, 2010
This post has two batch scripts: 1. Batch script to rename files with zero padded number series-prefix 2. Batch script to remove prefix of perticular length 1. Batch script to…
View Post
MySQL Podcast (Youtube)
RSS feed: MySQL Podcast (Spotify) MySQL Podcast (Spotify)
  • MySQL Major Version Upgrade Checklist (Zero Downtime Strategy)
    Upgrading MySQL major versions in production is never just a version bump - it’s a carefully planned process involving compatibility checks, replication strategy, testing, and controlled cut-over.In this episode, we walk through a practical MySQL Major Version Upgrade Checklist based on real-world DBA workflows. We are covering MySQL replication as base setup for upgrade. It […]
Search:
... ...
  • MySQL INSTANT DDL breaks EXCHANGE PARTITION
  • How to setup and use Percona Binlog Server (PBS)
  • MySQL Major Version Upgrade Checklist – how to
  • InnoDB Flushing is simple – explained
  • MySQL Tools for Performance Tuning and Test Data Generation

4 responses to “batch script to add remove prefix zero pad bulk file rename”

  1. nelson Avatar
    nelson
    May 21, 2021

    please help me….i need a batch to delete the sufix “.nusm” from mi files name….can help me please?

    Reply
  2. keith Avatar
    keith
    March 16, 2011

    I am looking to just rename *.jpg files to a fixed length. They all need to be 7 left of .jpg?
    Can your example pad script be modified to do that easily?
    Examples:
    1234567.jpg ok already.
    123456.jpg needs to be 0123456.jpg
    And of course they could start with 26.jpg (one or more numbers left of jpg) for example 0000026.jpg

    tia.

    Reply
  3. Kedar Avatar
    Kedar
    March 22, 2010

    You may read from and write to a file to remember last file name using batch script.
    Create a counter.txt to store the last variable value
    As per my script use following line to assign last counter value.

    set /p cnt=counter.txt

    Consider this:-

    Step 1: Create counter.txt in same directory of script.
    step 2: Use below script updated to read counter value from a text file and rename from that number.

    @echo off
    setLocal EnableDelayedExpansion

    :: set /a cnt=1
    set /p cnt=counter.txt
    )

    :Set0Pad
    set padcntr=0000000000%cnt%
    set str=!padcntr:~-%1!
    set renstr=%str%
    set /a cnt+=1

    Reply
  4. Renamer Avatar
    Renamer
    March 21, 2010

    I need to create an batch file that will
    rename a file on my F: drive

    named MyBackup 00001.qic

    to MyBackup nnnnn.qic (nnnnn = next available file number).

    For example if files exist:
    MyBackup 00002.qic
    MyBackup 00003.qic
    MyBackup 00004.qic
    MyBackup 00005.qic

    then rename MyBackup 00001.qic to MyBackup 00006.qic

    Yes, the file names always have a space just before the 5 digit number.

    Since I am just learning how to write .bat files for my Windows2000 Computers,

    File Renamer

    Reply
Change Is Inevitable
Designed & Developed by Code Supply Co.