Random Image Extraction from a folder by Bash Script

@echo off
setlocal

:: Initialization
set "ext=jpg"
set "source=folder 1"
set "target=folder 2"

:: Get count of images and select random image
for /f %%N in ('dir /b "%source%\*.%ext%"^|find /c /v ""') do (
  set /a "imageNum=%random% %% %%N"
)

:: Copy the image
if %imageNum% gtr 0 (set "skip=skip=%imageNum%") else set "skip="
for /f "%skip% eol=: delims=" %%F in ('dir /b "%source%\*.%ext%"') do (
  echo copy /y "%source%\%%F" "%target%\1.%ext%"
  exit /b
)

댓글

  1. shuf -zn8 -e *.jpg | xargs -0 cp -vt target/
    요런 방법도 있음 ~

    답글삭제

댓글 쓰기

이 블로그의 인기 게시물

파이썬으로 Homomorphic Filtering 하기

파이썬으로 2D FFT/iFFT 하기: numpy 버전