Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- del /S *.json
- for /f "tokens=*" %%f in ('dir /a:-D /s /b') do call :SUB_COPY "%%f" "I:\"
- for /f "tokens=*" %%f in ('dir /a:D /s /b') do rd "%%f"
- exit /B
- :SUB_COPY source_item target_dir
- if not "%~3"=="" (
- >&2 echo ERROR: too many arguments!
- )
- set "SOURCE=%~f1"
- if not defined SOURCE (
- >&2 echo ERROR: missing argument!
- exit /B 1
- ) else if not exist "%SOURCE%" (
- >&2 echo ERROR: source not found!
- exit /B 1
- )
- set "TARGET=%~f2"
- if not defined TARGET set "TARGET=."
- for /F "delims=" %%I in ('
- 2^> nul xcopy /L /S /E /Y /I "%SOURCE%" "%TEMP%\" ^| findstr /V /R "^[0-9]"
- ') do (
- > con echo "%%~I"
- call :SUB_DO "%%~I" "%TARGET%"
- )
- exit /B
- :SUB_DO source_file target_dir
- set "SUFFIX="
- :CHECK
- if exist "%~f2\%~n1%SUFFIX%%~x1" (
- set /A SUFFIX-=1
- ) else (
- 2> nul md "%~f2"
- > nul 2>&1 copy /B "%~f1" "%~f2\%~n1%SUFFIX%%~x1" && (
- echo INFO: copied "%~nx1" as "%~n1%SUFFIX%%~x1".
- ) || (
- >&2 echo ERROR: copying of "%~nx1" failed!
- exit /B 1
- )
- exit /B
- )
- goto :CHECK
Advertisement
Add Comment
Please, Sign In to add comment