Batch rename a group of files to odd numbers only?
May 14, 2007 12:26 PM   Subscribe

How do I batch rename a group of files so that the new names are all odd numbers?

I need to batch rename a group of image files. However, I want to rename them only with odd numbers, so that fileA, fileB and fileC become File1, File3, File5, File7, etc.

I have used ACDSee for batch rename jobs in the past, but I cannot figure out how to get it, or anything else, to start at a fixed number and then to skip one number as it increments, renumbering everything to odd numbers only.
posted by frogan to Computers & Internet (4 answers total)
 
File Renamer can do this (set the "Increment by" setting to 2).
posted by hootch at 12:47 PM on May 14, 2007


Doing this from a bash shell in *nix would be something like this:


#!/bin/bash
j=1;
for i in *.txt;
do
echo mv $i $j.txt
j=$((j+2));
done

posted by chrisamiller at 12:56 PM on May 14, 2007


Oops - my bad - remove the "echo" - it was there while I tested. This is the fixed version:

#!/bin/bash
j=1;
for i in *.txt;
do
mv $i $j.txt
j=$((j+2));
done

posted by chrisamiller at 12:57 PM on May 14, 2007


can you insert a "dummy file" in between every file in your list that you want to rename? Then just rename them all normally, and delete all the even numbered files (the dummies).

I realize that's a whack approach, but might be a good down and dirty way of accomplishing your task. Unless the task itself is to make a script or something that renames "oddly"
posted by iamkimiam at 1:07 PM on May 14, 2007


« Older Help me buy a work wardrobe for my new job in...   |   What's under my wall? Newer »
This thread is closed to new comments.