I have been trying to achieve in an easy way to copy image files to a server through ftp. Exiting files are using P123456 structure and new files should receive a _number after them like P123456_1. I haven't managed to make them go sequentially but only in random mode with the below code.
set work=%temp%\%random%-%random%
mkdir "%work%"
set archives=*.rar
for %%A in (%archives%) do (
"%ProgramFiles(x86)%\7-Zip\7z.exe" e -o"%work%" "%%~A"
for %%F in ("%work%\*") do copy "%%~F" "%%~nF_%random%%%~xF"
)
rmdir "%work%"
The above code would be suffice if the new files would generate random numbers for each file in the archive but if i have P1, P2 and P3 in the the archive the batch would output P1_random-number, P2_same-random-number, P3_same-as-the-first-two "random" numbers instead of P1_random, P2-other-random etc.