Batch file Question

Closed
Gita - Sep 8, 2009 at 11:14 PM
SenHu Posts 15 Registration date Friday May 22, 2009 Status Member Last seen February 2, 2010 - Sep 9, 2009 at 03:36 PM
Hello,
I want to rename my files (*.PDF), my files are distributed in different folders and directories how can I rename them?
Related:

1 response

SenHu Posts 15 Registration date Friday May 22, 2009 Status Member Last seen February 2, 2010 14
Sep 9, 2009 at 03:36 PM
How do you want to rename them ? For example, the following script will rename them 1.PDF, 2.PDF, 3.PDF, etc. I am adding a lot of comments so you can modify the script to meet your requirements.



# Script renamePDF.txt

# Go to the folder where PDF files are stored.
# PDF files can be distributed anywhere within this folder. If they
# are on the entire computer, use "C:/".
cd "C:/somefolder"

# We will store the count of PDF files in the following variable.
# We will start the count at 1.
var int count
set $count = 1

# Collect a list of PDF files.
var str list ; lf -r -n "*.PDF" > $list

# Go thru files one by one.
while ($list <> "")
do

    # Get the next file.
    var str file ; lex "1" $list > $file

    # We will rename this file to $count.PDF.
    system rename ("\""+$file+"\"") ("\""+makestr(int($count))+".PDF"+"\"")

done



Script is in biterscripting ( http://www.biterscripting.com ). Test it first with sample files before using it on real files. To try, save the script as C:/Scripts/renamePDF.txt, start biterscripting, enter the following command.


script "C:/Scripts/renamePDF.txt
2