1.

Solve : Find files with specific parameter?

Answer»

Hi,
Im looking for a Command to find all files on a specific date given with a parameter.

For EXAMPLE I need all filles of today

Dir | find "07/11/2012" -> OK, but now with a specific parameter like this

echo %date:~4,10% (gives today in substring)

I wont SOMETHING like this

dir | find | %date:~4,10%

But it doesnt WORK You have all the pieces, just not together in the same place:

Code: [Select]dir | find "%date:~4,10%"

Ok thank you and how can I copy the founded files to a dir ?If your DIR output is in this format WITHOUT the 24 hour clock time.
Code: [Select]11/28/11 08:47 AM 26 testfile.txtThen this should work
Code: [Select]@echo off
FOR /F "Tokens=4*" %%G IN ('dir /a-d ^| find "%date:~4,10%"') DO COPY "%%H" "C:\Some Directory"it gives me an error of: %%g was unexpected at this timeCopy and paste it - it works here.Copy and paste (change dir) it but doesnt workWhat happens when you run this? Copy and paste the dos screen output.

Code: [Select]@echo off
FOR /F "Tokens=4*" %%G IN ('dir /a-d ^| find "%date:~4,10%"') DO echo COPY "%%H" "C:\Some Directory"
pauseQuote from: eclectica on July 11, 2012, 08:37:52 AM

it gives me an error of: %%g was unexpected at this time
Because you are trying to run the code from the command line. That would be the only way you would get that error.
Code: [Select]C:\batch files>FOR /F "Tokens=4*" %%G IN ('dir /a-d ^| find "%date:~4,10%"') DO COPY "%%H" "C:\Some Directory"
%%G was unexpected at this time.
You need to put the code I gave to you and save it to a text file with a .BAT extension.


Discussion

No Comment Found