Page 1 of 1

Search todays folder and copy to destination

Posted: 08 Jul 2022 09:45
by foncesa
Hi,

I want to search source folder for todays date and if it exits then copy a particular folder from it, to shared network destination and extract all the files from it and paste it.

source folder c:/Reports/(todaysdate)
particular folder : softimages
network 192.168.1.130
user xxx
password xxx
destination folder f:\images
copy all files from softimage to f:\images

I have this codes to search for date folder and your expert help is required.

Code: Select all

@echo off
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"

set "datestamp=%dd%%mm%%yyyy%_FR
echo "%datestamp%"

Re: Search todays folder and copy to destination

Posted: 09 Jul 2022 05:30
by aGerman
Maybe something about like that (not tested)

Code: Select all

@echo off &setlocal

for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "datestamp=%dd%%mm%%yyyy%_FR

if not exist "C:\Reports\%datestamp%\softimages" exit /b

net use Z: \\192.168.1.130\F$\images password /user:domain\username 
robocopy "C:\Reports\%datestamp%\softimages" Z: /r:0 /w:0
Update password, domain, and username accordingly (and maybe the drive letter if Z is already used).

Steffen