# Solved: Need help - batch copy w/ todays date and specified extensions



## thmpr52 (Oct 28, 2008)

Hello,

I am trying to create a batch file to be placed on a Windows 2003 Server to search a particular directory for files that have the following paramaters:

- today's date
- extension of .wcx
- extension of .csv

The resulting files would be copied to another location to be encrypted using gpg. For the first part, I have found from another thread an answer posted by devil_himself for the date part:

::Copy Files Made Or Modified Today
@echo off
setlocal
set source=d:\ci\an\print\temp\pfiles
set dest=d:\wcpols
pushd "%source%"
set t=%date:~4%
for /f %%a in ('dir /b /a-d /o-d') do call ROCESS "%%a"
goto :eof
popd
ROCESS
for /f %%j in ('echo %~t1') do set d=%%j
if "%d%"=="%t%" copy %1 "%dest%"
goto :eof

I just need to know how to add the parameters to limit the copy of files with today's date AND also with the two listed extensions.

My second concern is with the gpg. I am probably in the wrong section for this inquiry but, I will try anyways. I cannot seem to find a command to encrypt all files within a specified directory. There are commands to do this for linux and other languages but not for dos.

Thank you in advance for your assistance!


----------



## TheOutcaste (Aug 8, 2007)

Welcome to TSG!

Change the For statement as follows and add a second one for the 2nd extension

```
for /f %%a in ('dir [B][COLOR=Red]*.wcx[/COLOR][/B] /b /a-d /o-d') do call :PROCESS "%%a"
for /f %%a in ('dir [B][COLOR=Red]*.csv[/COLOR][/B] /b /a-d /o-d') do call :PROCESS "%%a"
```
Downloaded gpg and tested, looks like the same commands for linux would work for DOS:

gpg -e -r Jerry --multifile c:\test\*.*

This encrypted all the files in the C:\Test folder.

HTH

Jerry


----------



## thmpr52 (Oct 28, 2008)

Excellent...Thank you so much! As for The gpg command, it seems to work fine when typed into a command prompt. When I place it into the bat file and do a test run it will do nothing. I added the path to where the gpg app is and even made the encrypt command a separate bat file to test. Still nothing happens.

Thank you again for your time!


----------



## Squashman (Apr 4, 2003)

Post your code.


----------



## thmpr52 (Oct 28, 2008)

Nevermind...I put it in its own .bat file to run 1 minute after the copy batch file ran. Thank you again!


----------

