Renaming and Moving Files in Bash

Posted by KT on Stack Overflow See other posts from Stack Overflow or by KT
Published on 2010-03-30T21:19:02Z Indexed on 2010/03/30 21:23 UTC
Read the original article Hit count: 417

Filed under:
|

HI, I'm completely new to Bash and StackOverflow.

I need to move a set of files (all contained in the same folder) to a target folder where files with the same name could already exist.

In case a specific file exists, I need to rename the file before moving it, by appending for example an incremental integer to the file name.

The extensions should be preserved. The file names could contain dots in the middle.

Originally, I was thinking about comparing the two folders to have a list of the existing files (I did this with "comm"), but then I got a bit stuck. I think I'm just trying to do things in the most complicated possible way.

Any hint to do this in the "bash way"?

© Stack Overflow or respective owner

Related posts about bash

Related posts about unix