PPRuNe Forums - View Single Post - a fast way to replace 1000+ files?
View Single Post
Old 25th Mar 2009, 21:07
  #12 (permalink)  
RandiR
 
Join Date: Mar 2009
Location: City
Posts: 1
Likes: 0
Received 0 Likes on 0 Posts
Script to copy over 1600 bitmap files

Massey1Bravo has the following requirement:

Does anyone know of a command or software that can copy and replace multiple files? I have about 1600 different bitmap files in a folder that needs to be replaced by copies of a single white bitmap, and it will take some major effort to copy and rename every single file manually.
Hi Massey1Bravo:

I will write a script for you.

I will assume the following.

1. You have over 1600 bitmap files in the folder "C:/Bitmaps" and, possibly, its subfolders. Their file extension is .bmp.
2. You want to copy over each of these files a single white bitmap stored at "C:/MasterBitmap.bmp".
Here is my script. It is written in biterscripting. (Download biterscripting free, if you don't have it. The installation instructions are at http://www.biterscripting.com/install.html . It is excellent for doing a lot of things like this.)

(I will admit that I am following one of the sample scripts that came with biterscripting - so this is not all my original work.)

Code:
 
 
# Collect a list of files that are to be copied over.
car str filelist ; find -r -n "*.bmp" "C:/Bitmaps" > $filelist
 
while ($filelist <> "")
do
    # Get the next file.
    var str file ; lex "1" $filelist > $file
    # The full path name of the file is in $file. Delete, then copy.
    system del ("\""+$file+"\"")
    system copy "C:/MasterBitmap.bmp" ("\""+$file+"\"")
done

Save the script in some file (say, C:/X.txt), start biterscripting and run the command

Code:
script "C:/X.txt"
That's it.

Let me know if this works for you.

Randi
RandiR is offline