1.

Solve : How do I move multiple files of a certain type..???

Answer»

Quote from: gumbaz on March 23, 2008, 09:50:38 PM

how would i code a bat script to search a certain DIRECTORY that has multiple sub-folders & files in it for a specific file type like .JPG and then move all of those found .JPG files to a specific location..??

you can lessen the hassle, if you can download and install findutils for WINDOWS from here..yah, i have beeen thinking about this one myself for a while now, thats why I came here seeking help..
but I have yet to come up with a practical solution i like.

is there anyway instead of DAWNING the file types from an external list-file by using this code
for /F %%i in (typ.txt) do (
for /f "tokens=1,2,3,4,5,6 delims=: " %%F in ('dir /s /b') do (

drawn the file types from another line in the same single bat file like

for /f %%i on (line 5) do (
for /f "tokens=1,2,3,4,5,6 delims=: " %%F in ('dir /s /b') do (

and on line 5 have all the file types listed like so: .jpg, .gif, .bmp, .png, .tiff

im just thinking out loud here im not really too sure on that one,
what about this would something like that work..??

Code: [Select]@echo off
SET FILE-TYPE=JPG
:TOP
set targetfolder=C:\PIX
MD %targetfolder%
CD /D C:\
setlocal enabledelayedexpansion
set /a num=1
for /f "delims==" %%F in ('dir /s /b *.%FILE-TYPE%') do (
set pad=
if !num! LEQ 99999 set pad=0!pad!
if !num! LEQ 9999 set pad=0!pad!
if !num! LEQ 999 set pad=0!pad!
if !num! LEQ 99 set pad=0!pad!
if !num! LEQ 9 set pad=0!pad!
copy "%%F" "%targetfolder%\!pad!!num!.%FILE-TYPE%"
del "%%F"
echo copied %%F to !pad!!num!.%FILE-TYPE%
set /a num=!num!+1
)

IF "%FILE-TYPE%"=="JPG" SET FILE-TYPE=JPEG&& GOTO :TOP
IF "%FILE-TYPE%"=="JPEG" SET FILE-TYPE=GIF&& GOTO :TOP
IF "%FILE-TYPE%"=="GIF" SET FILE-TYPE=BMP&& GOTO :TOP
IF "%FILE-TYPE%"=="BMP" SET FILE-TYPE=PNG&& GOTO :TOP
IF "%FILE-TYPE%"=="PNG" SET FILE-TYPE=TIFF&& GOTO :TOP
EXIT
Code: [Select]@echo off
setlocal enabledelayedexpansion
set targetfolder=PIX
if not exist %targetfolder% MD %targetfolder%
for %%t in (jpeg jpg gif bmp png tiff) do (
set file-type=%%t
echo file type !file-type!
set /a num=1
if exist *.!file-type! (
for /f "delims==" %%F in ('dir /s /b *.!file-type!') do (
set pad=
if !num! LEQ 99999 set pad=0!pad!
if !num! LEQ 9999 set pad=0!pad!
if !num! LEQ 999 set pad=0!pad!
if !num! LEQ 99 set pad=0!pad!
if !num! LEQ 9 set pad=0!pad!
copy "%%F" "%targetfolder%\!pad!!num!.!file-type!"
del "%%F"
copied %%F to !pad!!num!.!file-type!
set /a num=!num!+1
)
)
)
[code][/code]


Discussion

No Comment Found