Question : Script to move files to multiple directories only to include the current date

An expert, billprew recently created a script for me to move files into four different directories.  I need to modify this script to only move files from C:\temp that are within the current date that the script is run.  Can anyone assist?  The c:\temp may contain files from the day before or day after but I only want to move files on the day I run the script.

@echo off
setlocal EnableDelayedExpansion
 
REM Define source folder, and base for destination folders
set FromDir=c:\temp
set DestDir1=C:\folder\upload
set DestDir2=C:\folder2\upload
set DestDir3=C:\folder3\upload
set DestDir4=C:\folder4\upload
 
REM Loop through allfiles in source folder, calculate a dest folder, and move them
set Folder=0
for %%A in ("%FromDir%\*") do (
  set /A "Folder = (!Folder! %% 4) + 1"
  call :CopyFile "%%A" "DestDir!Folder!"
)
 
:CopyFile
  ECHO move "%~1" "!%~2!"
  exit /b

Answer : Script to move files to multiple directories only to include the current date

Give this a try, I think it's an easy way to handle what you want.

It does assume your %DATE% variable ends in MM/DD/YYYY though, so if you do

ECHO %DATE%

at a command prompt and that isn't the case then we need to adjust the SET of Today a bit.

~bp
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
@echo off
setlocal EnableDelayedExpansion
 
REM Assumes %DATE% ends in MM/DD/YYYY format, adjust as needed
set Today=%DATE:~-2,2%%DATE:~-10,2%%DATE:~-7,2%
 
REM Define source folder, and base for destination folders
set FromDir=c:\temp
set DestDir1=C:\folder\upload
set DestDir2=C:\folder2\upload
set DestDir3=C:\folder3\upload
set DestDir4=C:\folder4\upload
 
REM Loop through allfiles in source folder, calculate a dest folder, and move them
set Folder=0
for %%A in ("%FromDir%\*%Today%*") do (
  set /A "Folder = (!Folder! %% 4) + 1"
  call :CopyFile "%%A" "DestDir!Folder!"
)
 
:CopyFile
  ECHO move "%~1" "!%~2!"
  exit /b
Random Solutions  
 
programming4us programming4us