rather than rename, i'd just make a dir full of links:
harp:~ > cat a.rb
require 'fileutils'
dir, dir_full_of_links, ignored = ARGV
dir_full_of_links ||= dir + '.d.links'
d, f, fu = Dir, File, FileUtils
glob = f.join dir, '*'
srcs = d.glob(glob).map{|path| f.expand_path path}
link = 'a'
dsts = srcs.map{|path| f.join dir_full_of_links, link.succ!}
fu.rm_rf dir_full_of_links
fu.mkdir_p dir_full_of_links
dsts.sort_by{ rand }
srcs.zip(dsts) do |src, dst|
puts "#{ src } -->> #{ dst }"
fu.ln_s src, dst
end
harp:~ > ls -ltar tmp
total 716
-rw-rw-r-- 1 ahoward ahoward 393 May 5 05:30 G2006050506.sfctmp.dat.hdr
-rw-rw-r-- 1 ahoward ahoward 393 May 5 11:30 G2006050512.sfctmp.dat.hdr
-rw-rw-r-- 1 ahoward ahoward 260640 May 5 11:30 G2006050512.sfctmp.dat
-rw-rw-r-- 1 ahoward ahoward 393 May 5 17:30 G2006050518.sfctmp.dat.hdr
-rw-rw-r-- 1 ahoward ahoward 260640 May 5 17:30 G2006050518.sfctmp.dat
-rw-rw-r-- 1 ahoward ahoward 90112 May 23 09:30 G2006050506.sfctmp.dat
drwxrwxr-x 2 ahoward ahoward 8192 Jul 9 09:25 .
drwx------ 170 ahoward ahoward 81920 Jul 9 09:26 ..
harp:~ > ruby a.rb tmp
/home/ahoward/tmp/G2006050506.sfctmp.dat -->> tmp.d.links/b
/home/ahoward/tmp/G2006050506.sfctmp.dat.hdr -->> tmp.d.links/c
/home/ahoward/tmp/G2006050512.sfctmp.dat -->> tmp.d.links/d
/home/ahoward/tmp/G2006050512.sfctmp.dat.hdr -->> tmp.d.links/e
/home/ahoward/tmp/G2006050518.sfctmp.dat -->> tmp.d.links/f
/home/ahoward/tmp/G2006050518.sfctmp.dat.hdr -->> tmp.d.links/g
harp:~ > ls -ltar tmp.d.links/
total 88
lrwxrwxrwx 1 ahoward ahoward 44 Jul 9 09:26 g -> /home/ahoward/tmp/G2006050518.sfctmp.dat.hdr
lrwxrwxrwx 1 ahoward ahoward 40 Jul 9 09:26 f -> /home/ahoward/tmp/G2006050518.sfctmp.dat
lrwxrwxrwx 1 ahoward ahoward 44 Jul 9 09:26 e -> /home/ahoward/tmp/G2006050512.sfctmp.dat.hdr
lrwxrwxrwx 1 ahoward ahoward 40 Jul 9 09:26 d -> /home/ahoward/tmp/G2006050512.sfctmp.dat
lrwxrwxrwx 1 ahoward ahoward 44 Jul 9 09:26 c -> /home/ahoward/tmp/G2006050506.sfctmp.dat.hdr
lrwxrwxrwx 1 ahoward ahoward 40 Jul 9 09:26 b -> /home/ahoward/tmp/G2006050506.sfctmp.dat
drwx------ 171 ahoward ahoward 81920 Jul 9 09:26 ..
drwxrwxr-x 2 ahoward ahoward 4096 Jul 9 09:26 .
regards.
-a
···
On Mon, 10 Jul 2006, Bil Kleb wrote:
Got this request yesterday and still haven't had
time to decipher it and code it -- I figured I'd
throw it out here and see what you folks come up with:
Eric wrote:
I want to change the names of several hundred files to random numbers
(without overwriting any files). I have a bunch of pictures for our
reception, but they're basically in chronological order by their current
filenames. But I want the slideshow to play in random order, so I need to
randomize the filenames.
I'll also ask why the slideshow software can't just be
told to show things randomly...
Thanks,
--
suffering increases your inner strength. also, the wishing for suffering
makes the suffering disappear.
- h.h. the 14th dali lama