Sorry about that: I used find2perl to get the syntax of File::Find:
#! /usr/bin/perl -w eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' if 0; #$running_under_some_shell use strict; use File::Find (); # Set the variable $File::Find::dont_use_nlink if you're using AFS, # since AFS cheats. # for the convenience of &wanted calls, including -eval statements: use vars qw/*name *dir *prune/; *name = *File::Find::name; *dir = *File::Find::dir; *prune = *File::Find::prune; # Traverse desired filesystems File::Find::find({wanted => \&wanted}, "ARGV[0]"); exit; sub wanted { print("$name\n"); } Which gives me the result I want - printed to STDOUT - but to change this to handle every file/folder (and get the top folder name for renaming) is what I hoped some of you could "hint" me with. Sorry if it was unclear -----Oprindelig meddelelse----- Fra: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED] Sendt: 5. juli 2004 22:27 Til: [EMAIL PROTECTED] Emne: Re: File::Find Jakob Kofoed wrote: > I am trying to create a script which can traverse down a folder > structure to list all files and folders and then rename all files > or folders not called ".dat". > > Fx I have top folders called a 5 digit numbers and under here a > number of files and folders (in various depths). I would like to > give every folder or file not called ".dat" a prefix named after > the 5 digit top folder. > > I can traverse down the structure and find all files and folders > using File::Find but I cant figure out how to pick up the top > folder name for the renaming of the files/folders below. > > Can anybody give me a hint to get on with this? Show us what you have so far, or else it's difficult to give a "hint" at that detailed level. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>