[TriLUG] File renaming question

Alan Porter porter at trilug.org
Mon Dec 3 11:47:31 EST 2007


> 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.

In bash...

for x in * ; do c=$(($c+1)) ; mv $x ../tmp2/file$c ; done


Alan






.




More information about the TriLUG mailing list