Problem with script to move files

0

I am trying to create a script (cmd) in Windows to move files of any type of extension from one folder to another but it is giving me problem after problem, every time I execute it I get the error "You can not find the specified route", I've already tried everything but I do not know where I fail, here's the script I've been doing so far:

:============================|
: Script para mover archivos |
:============================|


    @echo off
    cls
    setlocal enabledelayedexpansion

    set /p tipo="¿Que tipo de archivos desea copiar? Introduzca su extension..."
    echo Usted quiere mover los archivos de tipo ".%tipo%"

    echo.
    set /p origen="Introduzca la ruta de origen..."
    echo La ruta de origen seleccionada ha sido: %origen%

    echo.
    set /p destino="Introduzca la ruta de destino..."
    echo Sus archivos se copiaran en el siguiente destino: %destino%

    echo.
    for /f %%a in ('dir /s /b "%origen%"^|find ".%tipo%"') do (
     echo Moviendo:
     echo.
     echo %%a
     move "%%a" "%destino%"

    )

    echo.
    echo Sus archivos se han movido correctamente.
    timeout /t 5

    echo.
    echo Gracias por usar mi script.
    pause >nul
    
asked by relyx 23.06.2018 в 13:50
source

1 answer

0

Try this way, it should work (it has cost me several editions to play as little as possible your script ;-)):

:============================|
: Script para mover archivos |
:============================|


    @echo off
    set /p tipo=¨Qu‚ tipo de archivos desea copiar? Introduzca su extensi¢n: 
    echo Usted quiere mover los archivos de tipo ".%tipo%"

    echo.
    set /p origen=Introduzca la ruta de origen: 
    echo La ruta de origen seleccionada ha sido: %origen%

    echo.
    set /p destino=Introduzca la ruta de destino: 
    echo Sus archivos se copiar n en el siguiente destino: %destino%

    echo.
    for %%a in ("%origen%\*.%tipo%") do (
     echo Moviendo:
     echo.
     echo %%a
     move "%%a" "%destino%"

    )

    echo.
    echo Sus archivos se han movido correctamente.
    timeout /t 5

    echo.
    echo Gracias por usar mi script.
    pause >nul

To accentuate "Your files will be copied to the next destination" open a command window and type echo to > a.txt. Open a.txt, copy the first (invisible) character and paste it into your file.
You can also change the echo line %% to before the move command by echo %% ~ nxa to not show the entire path of the files.

    
answered by 30.06.2018 в 17:44