How to duplicate one file … a lot

I had to duplicate a file… over a thousand times, for a test.

For the MacOS, I created a shell script to do this:

#!/usr/bin/env bash

# I'm passing in the filename as a parameter to the shell script,
# which is accesible through $1
for (( i = 0; i < 2000; i++ )); do
	cp -p "$1" "${i}_$1"
done

On Windows, I opened a command window ( Start -> Run -> cmd.exe [Hit enter] ), changed directories to my pictures folder, then typed:

for /L %f in (1,1,2000) do copy MYDOG.JPG %fMYDOG.JPG

Thanks to my co-worker for showing me the Windows tip!

References:
http://www.webmasterworld.com/webmaster/3556284.htm

Leave a Reply

Your email address will not be published. Required fields are marked *