[TriLUG] File renaming question

Craig Taylor ctalkobt at gmail.com
Mon Dec 3 11:47:54 EST 2007


Just 1 way to do it: 

ls | awk '{ print "mv " $0 " file" NR;}'

will give you a list of mv commands  for each.. wrap the above in ` 's
if you trust it or pipe it to a script file and sh it. 

- Craig Taylor

On Mon, 2007-12-03 at 11:38 -0500, Mike Norwood wrote:
> Hello,
> 
> I think this should be really easy, but am growing dumber as I age.  I 
> need to be able to take an undetermined number of files, could be 1 or 2, 
> could be 30 and move them to another directory as file1, file2, file3, 
> etc.  The names in the first directory could apparently be anything, 
> and I am not concerned with the order they are renamed, just as long as 20 
> files comes out as file1 through file20.  Please let me know if this 
> question is confusing, and I can try to give more details.
> 
> Thanks in advance for any help.
> 
> Mike Norwood
> 




More information about the TriLUG mailing list