Move files folder by folder with bat file


I don't understand what is your solution. I'm so sorry
 

My Computer

System One

  • OS
    Windows 11 Home 23H2
    Computer type
    Laptop
save this as a .bat
put that 7z file back in the other folder
run this new .bat and see if it moves it

Code:
::::::::::::::::::::::::::::::::::::::::::::
:: Automatically check & get admin rights V2
::::::::::::::::::::::::::::::::::::::::::::
@echo off
CLS
ECHO.
ECHO =============================
ECHO Running Admin shell
ECHO =============================

:init
setlocal DisableDelayedExpansion
set "batchPath=%~0"
for %%k in (%0) do set batchName=%%~nk
set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
setlocal EnableDelayedExpansion

:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )

:getPrivileges
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
ECHO.
ECHO **************************************
ECHO Invoking UAC for Privilege Escalation
ECHO **************************************

ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
ECHO args = "ELEV " >> "%vbsGetPrivileges%"
ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
ECHO args = args ^& strArg ^& " "  >> "%vbsGetPrivileges%"
ECHO Next >> "%vbsGetPrivileges%"
ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
"%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %*
exit /B

:gotPrivileges
setlocal & pushd .
cd /d %~dp0
if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul  &  shift /1)

::::::::::::::::::::::::::::
::START
::::::::::::::::::::::::::::
REM Run shell as admin (example) - put here code as you like
ECHO %batchName% Arguments: %1 %2 %3 %4 %5 %6 %7 %8 %9
move /y "D:\SOURCE\*.*" "D:\DESTINATION"
 

My Computer

System One

  • OS
    Windows 11 Pro
I get the problem: Móvil (ó).

I'm reading about how to get a solution, but I can't dedicate time now.

Thanks to all.
 

My Computer

System One

  • OS
    Windows 11 Home 23H2
    Computer type
    Laptop
(also - not sure as i dont have the same language keyboard as you, but possibly take the ó in Móvil and change it to o to avoid any character issues/conflicts?)

^ you referring to what i said on page 1?
 

My Computer

System One

  • OS
    Windows 11 Pro
The batch file fails, simply because there's a missing call to Code Page before using Spanish (or non-English) characters. Like ó.

Before W10 1903, Notepad defaulted to saving text in ANSI encoding format. Later Notepad editions switched to UTF-8. If you're writing UTF-8 files, then you need to first call "chcp 65001" in any CMD scripts that reference Spanish characters.

Correct batch file (saved in UTF-8 encoding):
Code:
chcp 65001 > nul
dir /b "C:\Users\GARLIN\Downloads\DIEGO\Bandeja de entrada"
dir /b "C:\Users\GARLIN\Downloads\DIEGO\Bandeja de entrada\000 Móvil\Vídeos"

move /y "C:\Users\GARLIN\Downloads\DIEGO\Bandeja de entrada\000 Móvil\Vídeos\*.*" "C:\Users\GARLIN\Downloads\DIEGO\Bandeja de entrada\Videos"

Running the same script, first without chcp and then after with chcp:

1738561407536.webp

Let's re-confirm our experiment, by switching to ANSI format.

Same batch file (except saved in ANSI). ANSI requires using "chcp 1252".
Code:
chcp 1252 > nul
dir /b "C:\Users\GARLIN\Downloads\DIEGO\Bandeja de entrada"
dir /b "C:\Users\GARLIN\Downloads\DIEGO\Bandeja de entrada\000 Móvil\Vídeos"

move /y "C:\Users\GARLIN\Downloads\DIEGO\Bandeja de entrada\000 Móvil\Vídeos\*.*" "C:\Users\GARLIN\Downloads\DIEGO\Bandeja de entrada\Videos"

1738561562685.webp


PowerShell probably handles this pathname encoding better (especially if using -LiteralPath) than the DOS-era copy and move commands.

I'm sure @LesFerch has a better explanation for how the wrong Code Page breaks all sorts of code.
 
Last edited:

My Computer

System One

  • OS
    Windows 7
Hi guys.

I already have the solution.

In the end the whole problem was the accents.

To do this, I have done two things, which I leave here in case someone could help you:

1. First, save the txt with ANSI (Unicode) encoding.

2. Then, open an MS-Dos window (CMD) and write the following:

Phrase or word with accents > Conf.txt

For example, Arándanos > Conf.txt

3. From the previous step we will obtain a txt with the word or phrase with the accents converted.

4. Copy to our txt to finish the code.

5. Save the txt as a bat file and the problem is solved.

Thanks to all.
 

My Computer

System One

  • OS
    Windows 11 Home 23H2
    Computer type
    Laptop

Latest Support Threads

Back
Top Bottom