Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

# Windows 7: DOS Command to Move Image Files to another Folder ?

 11 Aug 2015 #1 mave27 64 bit 1 posts DOS Command to Move Image Files to another Folder ? I have numerous image files (JPG/PNG format) stored in a folder. I would like to filter out (move to another folder) images that does NOT contain any of the following text : _thumb ; _tiny ; _zoom ; _std Example: image_thumb.jpg ; image_tiny.jpg ; image_zoom.jpg ; image_std.jpg ; image.jpg Output: image.jpg should be moved to another Folder Anyone care to share DOS Command prompt to achieve this ? Thanks in Advance. My System Specs
 .
 13 Aug 2015 #2 JonM Windows 7 Professional x64, RHEL 5,6,7 16 posts If I were you, I would seriously consider using something a bit more powerful like perl / powershell / VB etc. Having said that, here is a quick and dirty way of doing this: mkdir c:\temp\foo move *_*.jpg c:\temp\foo move *.jpg c:\temp\bar move c:\temp\foo\* . rmdir c:\temp\foo this creates a folder (c:\temp\foo) moves all jpg files which include an underscore into that folder moves all the remaining jpg files into a folder (c:\temp\bar) - change this to your desired output folder moves the underscored files back into the current folder removes c:\temp\foo This assumes the following: you are running it from the directory containing the files and have permissions to write to that directory you don't want any files with underscores rather than a set list of unwanted strings that c:\temp exists If you want something a bit more powerful, but insist on using DOS style commands, you would do well to have a look at the following batch file commands: FOR (to loop through all the files in a folder) FINDSTR (to filter out the files you want to move / keep) If you require this to be all as one line, you can combine commands with an ampersand (&): mkdir c:\temp\foo & move *_*.jpg c:\temp\foo & ... etc If you have a huge amount of files, or they are really large, you are better off investigating something which doesn't require moving all the other files somewhere, then moving them back. This will take a long time in some instances. My System Specs
 13 Aug 2015 #3 ignatzatsonic Windows 7 Home Premium SP1, 64-bit 12,050 posts Would a method within a GUI in Windows be OK or must this be a command line method? Can you identify all the files you want to move (or not move) by simply looking at their file names on a scrollable list? Roughly how many files on your hard drive with those 2 extensions need to be moved? Roughly how many files on your hard drive with those 2 extensions don't need to be moved? My System Specs
 .
 14 Aug 2015 #4 Ztruker Windows 10 Pro X64 6,291 posts Space Coast of Florida Maybe the find command: Quote: C:\WINDOWS\system32>find /? Searches for a text string in a file or files. FIND [/V] [/C] [/N] [/I] [/OFF[LINE]] "string" [[drive:][path]filename[ ...]] /V Displays all lines NOT containing the specified string. /C Displays only the count of lines containing the string. /N Displays line numbers with the displayed lines. /I Ignores the case of characters when searching for the string. /OFF[LINE] Do not skip files with offline attribute set. "string" Specifies the text string to find. [drive:][path]filename Specifies a file or files to search. If a path is not specified, FIND searches the text typed at the prompt or piped from another command. Use it to generate a list of files that do not contain _thumb ; _tiny ; _zoom ; _std Yo would have to run it multiple times and direct the output to a single file then edit the file to add the necessary move and target directories. My System Specs
 15 Aug 2015 #5 Pyprohly Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan 722 posts In a house Don't think OP is returning, but here's an answer. Code: :: th-378244.bat SourcePath DestinationPath @echo off setlocal EnableDelayedExpansion REM For each file in 'SourcePath', move the file to REM 'DestinationPath' if it's filename does not contain a REM string mentioned in 'ignore_files_containing_string'. :: set ignore_files_containing_string="_thumb";"_tiny";"_zoom";"_std" set case_sensitive=FALSE set recurse=FALSE :: if not "%~3"=="" echo Error: unexpected arguments& exit /b if "%~2"=="" echo Error: missing arguments& exit /b if not exist "%~2"\* echo Error: the destination path could not be found& exit /b if /i "%RECURSE%" equ "TRUE" ( set "recurse_=/s" ) else ( set "recurse_=" ) if /i "%CASE_SEN SITIVE%" equ "TRUE" ( set "case_sensitive_=" ) else ( set "case_sensitive_=/i" ) pushd "%~1" for /f "delims=" %%I in (' dir /a:-d /b %RECURSE_% "*" ') do ( set /a contains_string_counter=0 for %%J in (%IGNORE_FILES_CONTAINING_STRING%) do ( echo.%%~nxI| find %CASE_SENSITIVE_% "%%~J" >NUL && ( set /a contains_string_counter+=1 ) ) if exist "%%~I" ( if "!CONTAINS_STRING_COUNTER!"=="0" move "%%~I" "%~2" >NUL ) ) popd My System Specs