Copy Specific File from Network Folder

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
luzmen
Posts: 1
Joined: 13 Feb 2018 23:45

Copy Specific File from Network Folder

#1 Post by luzmen » 14 Feb 2018 00:12

Hello everyone,

I'm new with batch script...

I would like to create a batch file to copy a specific file from a Network folder to drive D:\CopyFile
Example:
The filename to be copied looks like this ABC021318X.zip where 021318 is the date while ABC and X are constant. When the batch file is running, it will prompt to input the date with the format mm/dd/yy then when hit Enter, it will copy ABC(date specified)X.zip from Network folder to drive D:\CopyFile. Further, if the date specified cannot be found, it will prompt a message "Specified File Not Found!".

Hoping your help.

Thank you in advance.


Luz

batnoob
Posts: 56
Joined: 19 Apr 2017 12:23

Re: Copy Specific File from Network Folder

#2 Post by batnoob » 23 Mar 2018 11:07

Code: Select all

@echo off
set/p  "moth=Enter month in mm/dd/yy format: "
set "month=%moth:~0,2%
set day=%moth:~3,-3%
set year=%moth:~6%
set "file=ABC%month%%day%%year%X.zip"
copy %file% D:\CopyFile 2>nul
if %ERRORLEVEL% GTR 0 (echo Specified File Not Found!)
pause

Post Reply