I am feeding filename and its mega publiclink to a sqlite3 to handle assets, so I can send a pdf with name and link to relatives… So, end product is not needing the full path, althought I will keep it in the DB as reference. I use md5 of filename as index so removing the path is interesting, althougth this is transitory cause I plan to use the file md5 instead.
Unfortunately, I haven't really used Windows in a long time. According to this, you should be able to use the variable %~nx<variable name>. And according to this, something like this should work:
for /f %%x in ('rclone lsf --files-only --recursive remote:/path/') do echo %~nxx
Keep in mind that I have absolutely not tested this since I haven't let Windows touch my computer for a long time now.
I already tried to use for loops and similar elements, but, inside bats and with spaces in filenames and non-ansi chars and ... blablabla... I was unable to find a safe way to implement it... Just chopping an chopping in going down levels (I went up to four subdirectories, then I stopped), as I was unable to make the recursivity work...