Renaming and Moving Files in Bash or Perl
Posted
by Katie
on Stack Overflow
See other posts from Stack Overflow
or by Katie
Published on 2010-03-30T21:19:02Z
Indexed on
2010/04/08
6:43 UTC
Read the original article
Hit count: 369
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 (in other words, that appended incremental integer should go before the extension). 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"? It's OK if it is done in a script other than bash script.
© Stack Overflow or respective owner