Batch Rename ###########

Ask for help and post your question on how to use XnView Classic.

Moderators: helmut, XnTriq, xnview

Post Reply
jasonc74
Posts: 3
Joined: Sat Apr 03, 2010 10:56 am

Batch Rename ###########

Post by jasonc74 »

Hi,

Until recently I renamed all my files as YYMMDD###, however I now rename to YYYYMMDD### as I have started scanning in more pre-2000 photos.
I normally use the the Batch Rename Name Template "<Date Taken [Ymd]>" with duplicate set to ### without any problems. However, if I delete a photo and want to rename the remainder, I used to be able to select the batch, press F2 and the auto-name template ######### would handle the rename. Now that the template is ###########, it seems to get confused.

eg.
If the first filename is "20091101001.JPG", it detects the starting number as 2911231817 rather than 20091101001.
When the first filename is "2009110101.JPG", it detects the starting number correctly as 2009110101 with a name template of ##########.
When the first filename is "091101001.JPG", it detects the starting number correctly as 91101001 with a name template of #########.

Am I doing something wrong or is the number too large for XnView.

Regards,
Jason
User avatar
ckv
Posts: 786
Joined: Wed Feb 02, 2005 2:30 pm
Location: Glow
Contact:

Re: Batch Rename ###########

Post by ckv »

jasonc74 wrote:Am I doing something wrong or is the number too large for XnView.
Yes, it seems that the number is too large for XnView. :( Max 32-bit integer is 4294967295 so all your YYYYMMDD### dates will be too large. If you can use just two digits (##) for the duplicate, then he number is small enough.

Applications doesn't have to be 64-bit to handle 64-bit integers so this problem could be fixed in the future. :)
XnView Tweak UI - Tool to customize your XnView beyond the regular XnView options.
UI-less Settings - Documentation of all the hidden settings in XnView.
XFAM - Tool to create and customize XnView file associations.
jasonc74
Posts: 3
Joined: Sat Apr 03, 2010 10:56 am

Re: Batch Rename ###########

Post by jasonc74 »

The reason I moved from ## to ### for the duplicate is that I am sometimes taking more than 99 photos in a single day.
I will change the duplicate to _### and revise my naming format to YYYYMMDD-###.

Now I just need to work out the easiest way to rename all my existing "YYYYMMDD### Description" files to "YYYMMDD-### Description". I can't use <Date Taken [Ymd]> as some of the photos are scans and therefore don't have EXIF dates.

Thanks,
Jason
Dreamer
XnThusiast
Posts: 4608
Joined: Sun Jul 25, 2004 9:08 pm

Re: Batch Rename ###########

Post by Dreamer »

I think it's not possible without EXIF dates in xnview.
Dreamer
jasonc74
Posts: 3
Joined: Sat Apr 03, 2010 10:56 am

Re: Batch Rename ###########

Post by jasonc74 »

In the end I just used a dir /s /b command to generate a file list and then used Excel LEFT & RIGHT commands to split the filename and create a batch file to add the "-". This also preserved any trailing description I have after the -###.
I'm sure I could have found a utility to do this for me but as a once off I thought this would just be easier.

Regards,
Jason
PatrickMc
Posts: 2
Joined: Sun May 31, 2009 3:10 pm

Re: Batch Rename ###########

Post by PatrickMc »

Perhaps, this could be done with strings instead of integers. Here is a script.



Code: Select all

# Script Y2K.txt
var string dir, list, path, file, name, prefix
cd $dir
find -n -r "*.jpg" > $list
while ($list <> "")
do
    lex "1" $list > $path ; stex -p "^/^[" $path > $file ; stex "]^.^l" $file > $name
    if ( { chen $name } == 9 )
    do
        # This file name is yymmdd. Make it yyyymmdd. If yy is < 50, we will make it 20yy.
        # If yy >= 50, we will make it 19yy.
        var integer year
        set $year = makeint( str ( { chex -p "2]" $name } ) )
        if ($year < 50)
            set $prefix = "20"
        else
            set $prefix = "19"
        endif
        set $file = $prefix+$file
        system rename ("\""+$path+"\"") ("\""+$file+"\"")
    done
    endif
done



To try, save the code in file C:/Scripts/Y2K.txt. The code is in biterscripting ( http://www.biterscripting.com ) scripting language. Run the script with this command in biterscripting.

script "C:/Scripts/Y2K.txt" dir("C:/test")


It will rename all .jpg files in C:/test folder according to the coded algorithm. (I have not tested the script. So, please test in a test folder first.)
Post Reply