Computer Hope
Microsoft => Microsoft DOS => Topic started by: anymouse on January 04, 2017, 11:10:31 AM
-
Modifying some code I found. Basically I am parsing a directory and subdirectory filelist out after a date and writing the info to a text file to use as input into 7 zip. I was going to use forfiles when I found out that one can not exclude directories when using -s. My problem is echoing out the file date using echo %%~tF. I get a blank line. or with other variants I get the colon . I am missing something here. I got stuck on the echo.
Current version of code:
@echo off
for /D %%D in ("c:\Docs\*.*") do (
if /I not "%%D"=="c:\docs\outlook data files" (
::store current directory
pushd "%%D"
::recurse through directory for file
for /R %%F in (%%D) do (
echo ok
echo :%%~tF
)
popd
)
)
The version gives:
ok
:
ok
:
Ultimately, I want to add an if to compare the file date to a date I specify and if >= echo file to the file list using something like : ECHO @PATH\@FILE>> "c:\test\ziplst.txt"
-
Quick sanity check... you want to find a folder under C:\Docs, called "C:\Docs\outlook data files", (which WILL be present?) and then echo the date and time of every single file in that folder, preceding each date with a colon? Is that right?
-
Please use code tags.
-
I initially looked under Help and Posting for how to insert code before posting. I looked for some other general stickies, couldn't find one though. Help had a lot of stuff on Polls, nothing on posting inline code in Posting. Do you have a code tag format link?
Search seemed to be dyfunctional. Perhaps I do not understand how to use the Search. I did a search on batch and date and one on just date, got nothing returned yet in just going through the forum pages found a couple of threads on batch and date.
-
. you want to find a folder under C:\Docs, called "C:\Docs\outlook data files"
C:\Docs\outlook data files gets excluded from the search since there is a not in the compare. %%D has current path & filename.
-
Started over and now have different problem. FileDate var is getting set to last file's date in the Echo for all files.
for /R "C:\test\" %%D in (*.*) do (
set FileDate=%%~tD
ECHO %%D: CurFDate: %%~tD: %FileDate:~0,10% >>I:\tem.txt
)
output:
C:\test\t1.dat: CurFDate: 10/15/2014 02:26 PM: 11/11/2014
C:\test\t2.dat: CurFDate: 10/15/2014 02:34 PM: 11/11/2014
C:\test\t3.txt: CurFDate: 11/16/2015 10:42 AM: 11/11/2014
C:\test\t4.txt: CurFDate: 12/31/2015 08:53 AM: 11/11/2014
C:\test\t5.txt: CurFDate: 05/11/2016 02:20 PM: 11/11/2014
C:\test\TestL2\t6subd.dat: CurFDate: 11/11/2014 01:56 PM: 11/11/2014
-
Because you are not using delayed expansion.