I used to do this with Hazel. I'd move everything from
~/Downloads/Archive/Videos etc. based on the file extension, and when a file with an identical name already existed, Hazel would just append a number to the file it was moving.
I wanted to write a shell script that would achieve this but I quickly realized I have no idea how to rename the files without any user input. The scheme to rename by could be a simple counter after the filename and it should only take place when
mv would otherwise overwrite the existing file. It should also be able to continue the counter should there already have been numerous instances with an identical filename. So, if I were moving
dirB/ that already has
file2.ext in it, the script should start counting at 3 and rename
Can anyone offer any guidance on how to go about achieving this? Preferably with a shell script but if not, then either in Ruby, Perl, or Python. Just knowing whether this is even possible with a shell script would help me.