Move files folder by folder with bat file


zelarra821

Member
Member
Local time
5:40 PM
Posts
79
OS
Windows 11 Home 23H2
Good morning.

I'm trying to create a bat file that copies files from different folders.

I've tried this code but I can't get it to work:

Code:
@echo off

::Mover audios

move /Y D:\Bandeja de entrada\000 Móvil\Audios\*.* D:\Bandeja de entrada\Audios

::Mover Documentos

move /Y D:\Bandeja de entrada\000 Móvil\Documentos\*.* D:\Bandeja de entrada\Documentos

::Mover Imágenes

move /Y D:\Bandeja de entrada\000 Móvil\Imágenes\*.* D:\Bandeja de entrada\Imágenes

::Mover Vídeos

move /Y D:\Bandeja de entrada\000 Móvil\Vídeos\*.* D:\Bandeja de entrada\Vídeos

::Mover ZZZ Comprobar

move /Y D:\Bandeja de entrada\000 Móvil\ZZZ Comprobar\*.* D:\Bandeja de entrada\ZZZ Comprobar

I've also been looking for a way to stop the command window from showing.

Can anyone tell me what I'm doing wrong?

Thank you very much.
 
Windows Build/Version
W11

My Computer

System One

  • OS
    Windows 11 Home 23H2
    Computer type
    Laptop
At first glance, your folder paths have spaces in them. You need to wrap them in double quotes.


“D:\Bandeja de entrada\000 Móvil\Vídeos\*.*”

“D:\Bandeja de entrada\Vídeos”
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
At first glance, your folder paths have spaces in them. You need to wrap them in double quotes.


“D:\Bandeja de entrada\000 Móvil\Vídeos\*.*”

“D:\Bandeja de entrada\Vídeos”
1738409596127.webp

1738409620354.webp

System can find path that I write in bat file
 

My Computer

System One

  • OS
    Windows 11 Home 23H2
    Computer type
    Laptop
Let's start with basics. Open a command prompt and run the following commands. Provide a copy of the output:

D:
cd "D:\Bandeja de entrada\000 Móvil\Audios"
cd "D:\Bandeja de entrada\Audios"

If either of the commands starting with "cd" fail then that path is not valid.

IMPORTANT: If you use the lines provided by @pseymour by copying and pasting them, make sure to ERASE the double quote marks and retype them. As shown in his post, these are "smart quotes" and need to be replaced with "straight quotes". Batch files hate smart quotes!

Example of a smart quote: “D:\Bandeja de entrada\Vídeos”
Now with straight quotes: "D:\Bandeja de entrada\Vídeos"

The visible difference here in the forum is minimal, but they are in fact different characters. Here is a better example where it is more obvious in Notepad:

Image1.webp
 

My Computers

System One System Two

  • OS
    Win11 Pro 24H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Kamrui Mini PC, Model CK10
    CPU
    Intel i5-12450H
    Memory
    32GB
    Graphics Card(s)
    No GPU - Built-in Intel Graphics
    Sound Card
    Integrated
    Monitor(s) Displays
    HP Envy 32
    Screen Resolution
    2560 x 1440
    Hard Drives
    1 x 2TB NVMe SSD
    1 x 4TB NVMe SSD
    1 x 4TB 2.5" SSD
    PSU
    120W "Brick"
    Keyboard
    Corsair K70 Mechanical Keyboard
    Mouse
    Logitech MX Master 3
    Internet Speed
    1Gb Up / 1 Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
  • Operating System
    Win11 Pro 23H2
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo ThinkBook 13x Gen 2
    CPU
    Intel i7-1255U
    Memory
    16 GB
    Graphics card(s)
    Intel Iris Xe Graphics
    Sound Card
    Realtek® ALC3306-CG codec
    Monitor(s) Displays
    13.3-inch IPS Display
    Screen Resolution
    WQXGA (2560 x 1600)
    Hard Drives
    2 TB 4 x 4 NVMe SSD
    PSU
    USB-C / Thunderbolt 4 Power / Charging
    Mouse
    Buttonless Glass Precision Touchpad
    Keyboard
    Backlit, spill resistant keyboard
    Internet Speed
    1Gb Up / 1Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
    Other Info
    WiFi 6e / Bluetooth 5.1 / Facial Recognition / Fingerprint Sensor / ToF (Time of Flight) Human Presence Sensor
This may be of small interest in naming of files, prohibited characters:

1738422274434.webp
 

My Computers

System One System Two

  • OS
    Win11 Pro RTM
    Computer type
    Laptop
    Manufacturer/Model
    Dell Vostro 3400
    CPU
    Intel Core i5 11th Gen. 2.40GHz
    Memory
    12GB
    Hard Drives
    256GB SSD NVMe M.2
  • Operating System
    Windows 11 Pro RTM x64
    Computer type
    PC/Desktop
    Manufacturer/Model
    Dell Vostro 5890
    CPU
    Intel Core i5 10th Gen. 2.90GHz
    Memory
    16GB
    Graphics card(s)
    Onboard, no VGA, using a DisplayPort-to-VGA adapter
    Monitor(s) Displays
    24" Dell
    Hard Drives
    512GB SSD NVMe, 4TB Seagate HDD
    Browser
    Firefox, Edge
    Antivirus
    Windows Defender/Microsoft Security
DO NOT edit batch files in Word!!! Word adds special formatting characters that are not visible. Use Notepad, Notepad++, etc.

Don't copy from Word into Notepad. Retype the commands from scratch.
 

My Computers

System One System Two

  • OS
    Win11 Pro 24H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Kamrui Mini PC, Model CK10
    CPU
    Intel i5-12450H
    Memory
    32GB
    Graphics Card(s)
    No GPU - Built-in Intel Graphics
    Sound Card
    Integrated
    Monitor(s) Displays
    HP Envy 32
    Screen Resolution
    2560 x 1440
    Hard Drives
    1 x 2TB NVMe SSD
    1 x 4TB NVMe SSD
    1 x 4TB 2.5" SSD
    PSU
    120W "Brick"
    Keyboard
    Corsair K70 Mechanical Keyboard
    Mouse
    Logitech MX Master 3
    Internet Speed
    1Gb Up / 1 Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
  • Operating System
    Win11 Pro 23H2
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo ThinkBook 13x Gen 2
    CPU
    Intel i7-1255U
    Memory
    16 GB
    Graphics card(s)
    Intel Iris Xe Graphics
    Sound Card
    Realtek® ALC3306-CG codec
    Monitor(s) Displays
    13.3-inch IPS Display
    Screen Resolution
    WQXGA (2560 x 1600)
    Hard Drives
    2 TB 4 x 4 NVMe SSD
    PSU
    USB-C / Thunderbolt 4 Power / Charging
    Mouse
    Buttonless Glass Precision Touchpad
    Keyboard
    Backlit, spill resistant keyboard
    Internet Speed
    1Gb Up / 1Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
    Other Info
    WiFi 6e / Bluetooth 5.1 / Facial Recognition / Fingerprint Sensor / ToF (Time of Flight) Human Presence Sensor
DO NOT edit batch files in Word!!! Word adds special formatting characters that are not visible. Use Notepad, Notepad++, etc.

Don't copy from Word into Notepad. Retype the commands from scratch.
I write all in Notepad. I only use Word to show quotes
 

My Computer

System One

  • OS
    Windows 11 Home 23H2
    Computer type
    Laptop
What happens if you manually type one of those lines? Just to be safe, type it from scratch - no copy / paste.
 

My Computers

System One System Two

  • OS
    Win11 Pro 24H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Kamrui Mini PC, Model CK10
    CPU
    Intel i5-12450H
    Memory
    32GB
    Graphics Card(s)
    No GPU - Built-in Intel Graphics
    Sound Card
    Integrated
    Monitor(s) Displays
    HP Envy 32
    Screen Resolution
    2560 x 1440
    Hard Drives
    1 x 2TB NVMe SSD
    1 x 4TB NVMe SSD
    1 x 4TB 2.5" SSD
    PSU
    120W "Brick"
    Keyboard
    Corsair K70 Mechanical Keyboard
    Mouse
    Logitech MX Master 3
    Internet Speed
    1Gb Up / 1 Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
  • Operating System
    Win11 Pro 23H2
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo ThinkBook 13x Gen 2
    CPU
    Intel i7-1255U
    Memory
    16 GB
    Graphics card(s)
    Intel Iris Xe Graphics
    Sound Card
    Realtek® ALC3306-CG codec
    Monitor(s) Displays
    13.3-inch IPS Display
    Screen Resolution
    WQXGA (2560 x 1600)
    Hard Drives
    2 TB 4 x 4 NVMe SSD
    PSU
    USB-C / Thunderbolt 4 Power / Charging
    Mouse
    Buttonless Glass Precision Touchpad
    Keyboard
    Backlit, spill resistant keyboard
    Internet Speed
    1Gb Up / 1Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
    Other Info
    WiFi 6e / Bluetooth 5.1 / Facial Recognition / Fingerprint Sensor / ToF (Time of Flight) Human Presence Sensor
try it with PowerShell and see if it works. just to narrow down testing

Code:
Move-Item -Path "D:\Bandeja de entrada\000 Móvil\Audios\*.*" -Destination "D:\Bandeja de entrada\Audios"

(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?)
 

My Computer

System One

  • OS
    Windows 11 Pro
DO NOT edit batch files in Word!!! Word adds special formatting characters that are not visible. Use Notepad, Notepad++, etc.

Don't copy from Word into Notepad. Retype the commands from scratch.
Agreed. That was a standard caveat back in DOS days when writing programs and early HTML coding.
 

My Computers

System One System Two

  • OS
    Win11 Pro RTM
    Computer type
    Laptop
    Manufacturer/Model
    Dell Vostro 3400
    CPU
    Intel Core i5 11th Gen. 2.40GHz
    Memory
    12GB
    Hard Drives
    256GB SSD NVMe M.2
  • Operating System
    Windows 11 Pro RTM x64
    Computer type
    PC/Desktop
    Manufacturer/Model
    Dell Vostro 5890
    CPU
    Intel Core i5 10th Gen. 2.90GHz
    Memory
    16GB
    Graphics card(s)
    Onboard, no VGA, using a DisplayPort-to-VGA adapter
    Monitor(s) Displays
    24" Dell
    Hard Drives
    512GB SSD NVMe, 4TB Seagate HDD
    Browser
    Firefox, Edge
    Antivirus
    Windows Defender/Microsoft Security
try it with PowerShell and see if it works. just to narrow down testing

Code:
Move-Item -Path "D:\Bandeja de entrada\000 Móvil\Audios\*.*" -Destination "D:\Bandeja de entrada\Audios"

(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?)
It works.

So, how should I create a new file to execute that powershell script?
 

My Computer

System One

  • OS
    Windows 11 Home 23H2
    Computer type
    Laptop
It works.

So, how should I create a new file to execute that powershell script?
use this template:

Code:
<# :
  @echo off
    powershell /nologo /noprofile /command ^
        "&{[ScriptBlock]::Create((cat """%~f0""") -join [Char[]]10).Invoke(@(&{$args}%*))}"
  exit /b
#>

# POWERSHELL_COMMANDS_HERE
 

My Computer

System One

  • OS
    Windows 11 Pro
use this template:

Code:
<# :
  @echo off
    powershell /nologo /noprofile /command ^
        "&{[ScriptBlock]::Create((cat """%~f0""") -join [Char[]]10).Invoke(@(&{$args}%*))}"
  exit /b
#>

# POWERSHELL_COMMANDS_HERE
1738450556745.webp

I think I'm doing something wrong...
 

My Computer

System One

  • OS
    Windows 11 Home 23H2
    Computer type
    Laptop
run it as admin and see what happens. depends on the perms set on that D: drive. i know you cant run commands directly in the root of C: without admin cmd
 

My Computer

System One

  • OS
    Windows 11 Pro
Execute in powershell window.

Bat files doesn't work
just ran the below and it worked. had a "test.txt" inside test and it moved it inside test2. non-admin. has to be a perms issue on your D: drive

Code:
<# :
  @echo off
    powershell /nologo /noprofile /command ^
        "&{[ScriptBlock]::Create((cat """%~f0""") -join [Char[]]10).Invoke(@(&{$args}%*))}"
  exit /b
#>

Move-Item -Path "C:\Users\ME\Desktop\test\*.*" -Destination "C:\Users\ME\Desktop\test2\"
 

My Computer

System One

  • OS
    Windows 11 Pro

Latest Support Threads

Back
Top Bottom