Solved Mass Move Batch file

migooz

New member
Local time
5:06 PM
Messages
5
Hey All, I have a list of files that I need to move (cut and paste) from location to another location.

Thanks in advance
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
dell
OS
Windows 7 Ultimate x64
Hi, can you describe a bit more about what you need?

By the sounds of what you've said, you have a text file containing a list of files to move?
 

My Computer

Computer type
PC/Desktop
OS
Windows 7 Professional x64, RHEL 5,6,7
Exactly JonM, i have a list of over than 3000 records and i want some of them (which already in list.txt) to be moved to another directory. (Cut and paste)
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
dell
OS
Windows 7 Ultimate x64
Here you are, Migooz. Just tweaked the batch script made in your previous thread.


Code:
:: th-378655.bat [TxtFileList] [DestinationPath]
@echo off
REM Move files/folders specified in a newline-delimited txtfile list to the location of 'DestinationPath'. 
 
set "default_list_path=C:\Users\%USERNAME%\Desktop\ListOfFilesToMove.txt"
set "default_destination_path=C:\Entries\in\ListOfFilesToMove.txt\will\be\moved\to\here" 
set "overwrite=FALSE"
 
if not "%~3"=="" echo Error: unexpected arguments& exit /b
if not "%~2"=="" ( set "destination=%2" ) else ( set "destination="%DEFAULT_DESTINATION_PATH:"=%"" )
if not "%~1"=="" ( set "list=%1" ) else ( set "list=%DEFAULT_LIST_PATH%" )
 
if not exist "%LIST:"=%" echo Error: list could not be found& exit /b
if not exist "%DESTINATION:"=%" echo Error: the destination path could not be found& exit /b
 
set /a counter=0
for /f "delims=" %%I in ('type "%LIST:"=%"') do (
    if exist "%%~fI" (
        if exist "%DESTINATION:"=%\%%~nxI" (
            if /i "%OVERWRITE%"=="TRUE" (
                set /a counter+=1
                move /y "%%~fI" "%DESTINATION:"=%" >NUL
            ) else (
                echo The path "%DESTINATION:"=%\%%~nxI" already exists.
            )
        ) else (
            set /a counter+=1
            move "%%~fI" "%DESTINATION:"=%" >NUL
        )
    ) else (
        echo No such item "%%~I".
    )
)
 
echo.& echo %COUNTER% files or folders were moved.
 

My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
thanks Pyprohly

thanks Pyprohly for your great support, but i cant move them to other directory other than C: is there something wrong
 
Last edited:

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
dell
OS
Windows 7 Ultimate x64
Could you elaborate on the issue? The script moves files to other drives well for me.
 

My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Back
Top