please I need help with this script. I need to recursively move one particular file into one particular folder. The particular file is in the same folder as the particular folder.
To make it clear.
I have tried this, but its not working recursively, when I add the script into the Movie1 folder and from the script I remove the cd Movie folder, then it will move the file into that folder. But I need to make it run from the Root. Thanks for anykind of idea.
cd Movie folder
for /f "delims=" %%i in ('dir /b /s "Subtitles.srt"') do move "%%~i" "Subtitles"
You are almost there
You need the first line to optionally force the script to cd and look in relative local drive
Then add relative subdirs
cd /D "%~dp0"
for /f "delims=" %%i in ('dir /b /s "Subtitles.srt"') do move "%%~i" "%%~dpiSubtitles"
If the folder names are \Subtitles folder
then you need to add that at the end i.e. "%%~dpiSubtitles folder"
C:\Users>"E:\Movie folder\script.bat"
C:\Users>cd /D "E:\Movie folder\"
E:\Movie folder>for /F "delims=" %i in ('dir /b /s "Subtitles.srt"') do move "%~i" "%~dpiSubtitles"
E:\Movie folder>move "E:\Movie folder\Movie1\subtitles.srt" "E:\Movie folder\Movie1\Subtitles"
1 file(s) moved.
E:\Movie folder>move "E:\Movie folder\Movie2\subtitles.srt" "E:\Movie folder\Movie2\Subtitles"
1 file(s) moved.
E:\Movie folder>move "E:\Movie folder\Movie3\subtitles.srt" "E:\Movie folder\Movie3\Subtitles"
1 file(s) moved.
E:\Movie folder>