1

I am currently using the following bat code to move my files from one folder to another

@echo off
set X=0
set "source=C:\<Source Folder Path>"
set "destination=D:\<Destination Folder Path>"
robocopy "%source%" "%destination%" /mov /minage:%X%
exit /b

However, I would like to move only a specified file within this source folder, rather than everything in this folder. Namely, if the excel file contains ABCXYZ as a prefix (eg file name: ABCXYZ-June2021.xls), it will be moved to my destination folder.

How would I go about achieving this?

DavidPostill
  • 153,128
  • 77
  • 353
  • 394

1 Answers1

0

However, I would like to move only a specified file within this source folder

Syntax

ROBOCOPY Source_folder Destination_folder [files_to_copy] [options]

Key

file(s)_to_copy : A list of files or a wildcard. (defaults to copying .)

Change your robocopy command to:

robocopy "%source%" "%destination%" ABCXYZ*.xls /mov /minage:%X%

See Robocopy "Robust File Copy" - Windows CMD - SS64.com for more information

DavidPostill
  • 153,128
  • 77
  • 353
  • 394