Make move rename conflicting files

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Often when "flattening" directory structures - using [for /d %i in (*) move /hqs "%i\*.*" "%_cwd"], destination files with the same name get overwritten (which in most cases is ok).
At times however I'd like to preserve the then overwritten files, moving the "overwriting" file to the destination directory (as before) but renaming it at the same time (preferably appending the name of the source directory).
Clearly, a batch could be written to do this, but - for performance reasons - I'd like to avoid checking in advance for a file collision (hey, what about a try/catch ;-)
Hence I'd suggest a new switch (maybe also /R could be drilled open a bit?) to do this, indicating what should be done in case of a file name conflict:
1: Insert immediate parent folder name before the extension (default)
2: Insert a running number before the extension.



... MOVE... /X? ... would result in a flat directory containing:

x (backup).cpp /X[1]
x (old).cpp /X[1]
x (1).cpp /X2
x (2).cpp /X2