You can do this to move files to the base folder using this command line:
for /R %a in (*) do @set f=%a& set f=!f:%cd%\=!& move "%a" !f:\=_!
Run it from the folder containing the folders 1969, 1970 .... IMPORTANT !: The delayed extension must be active for this line to work, so you must first activate it by running cmd.exe using the / V switch as follows: cmd /V
For instance:
>xcopy test backup /s test\1969\ar\1.jpg test\1969\ar\2.jpg test\1969\en\1.jpg test\1969\en\2.jpg test\1969\he\1.jpg test\1969\he\2.jpg test\1970\ar\1.jpg 7 File(s) copied >cd test >dir /B 1969 1970 >for /R %a in (*) do @set f=%a& set f=!f:%cd%\=!& move "%a" !f:\=_! >dir /B 1969 1969_ar_1.jpg 1969_ar_2.jpg 1969_en_1.jpg 1969_en_2.jpg 1969_he_1.jpg 1969_he_2.jpg 1970 1970_ar_1.jpg
Change the line so that the files are moved to another folder:
for /R %a in (*) do @set f=%a& set f=!f:%cd%\=!& move "%a" "\other\folder\!f:\=_!"
Or through this batch file:
@echo off setlocal EnableDelayedExpansion for /R %%a in (*) do set f=%%a& set f=!f:%cd%\=!& move "%%a" "\other\folder\!f:\=_!"
source share