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
Copy Specific File from Network Folder
Moderator: DosItHelp
Re: Copy Specific File from Network Folder
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