[OT, unix] Looking for recursive soft linking incantation
Jimmie Houchin
jhouchin at texoma.net
Fri Feb 8 20:40:07 UTC 2002
Couldn't this be done from Squeak?
Why go to an outside tool?
Honest questions, no offense intended?
Just trying to learn and understand.
Jimmie Houchin
Avi Bryant wrote:
> On Fri, 8 Feb 2002, Tim Rowledge wrote:
>
>
>>For all you unix gurus out there -
>>I'd like to be able to have a simple script that will run through the
>>VMMaker platforms tree and make a parallel tree with links between the
>>two; the tricky extra is that I need to apply a trivial transform to the
>>filenames.
>>
>>i.e. /foo/bar/one.[c,h] needs to become /foo/bar/[c,h]/one
>>
>
> This seems to do it, although you probably wanted something with a more
> widespread interpreter:
>
> #!/usr/local/bin/ruby
> require 'find'
>
> src = File.expand_path(ARGV[0])
> dest = File.expand_path(ARGV[1])
>
> Find.find(src) do |srcfile|
> destfile = srcfile.sub(src, dest)
> if FileTest.directory?(srcfile)
> Dir.mkdir(destfile) unless FileTest.exists?(destfile)
> elsif File.basename(srcfile) =~ /(.*)[.]([hc])/
> dir = File.dirname(destfile) + '/' + $2
> Dir.mkdir(dir) unless FileTest.exists?(dir)
> File.symlink(srcfile, dir + '/' + $1)
> else
> File.symlink(srcfile, destfile)
> end
> end
More information about the Squeak-dev
mailing list
|