Solved Move files from one folder to another on specific date

May 12, 2015 at 02:30:16
Specs: Windows 7
Hi,

need help witch batch script. The idea is to only move .txt files on the 15th of every month from VTO\Send folder to VTO\Old\Send folder. After the 15th VTO\Send folder is again filling with .txt files, and those files have same name every month. Since files have same name, they should be renamed or something like that, before moving from VTO\Send folder to VTO\Old\Send folder so they don't overwrite files that are already there.

Thanks in advance.


See More: Move files from one folder to another on specific date

Report •

#1
May 12, 2015 at 19:25:00
✔ Best Answer
tentative:
@echo off &setlocal
pushd c:\send
for %%a in (*.txt) do move %%~na.txt "old\%%~na_%date%.txt"
::== end batch
but you would do better to refined %date% to get rid of day-of-week with attendant spaces and also perhaps day since it's irrelevant. Since I don't know your local date format, I can't give the exact answer, but on mine, date format: dofw mm/dd/yyyy
(where "dofw" is like Sun, Mon, Tue etc) it would look like:
for /f "tokens=2,4 delims= \" %%a in %date% set dt=%%b_%%a
echo %dt%
rem "2015_05"
for %%a in (*.txt) do move %%~na.txt "old\%%~na_%dt%.txt"



Report •
Related Solutions


Ask Question