Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Listing all files from a date interval “Batch file”

Featured Replies

I need to do a batch file wich order all files by a date interval, example:

 

@echo off echo Input the date(dd/mm/yyyy):
set /p compDate=

 

::After that i will compare from the actual day (%date%), example:

set interval = %compDate% - %date%... Something like that

::After that i need to list all files from a specific directory, example:

 

echo Input the directory:
set /p directory=
SET Exit= %UserProfile%\Desktop\test.txt

 

::After that i might i need the dir /tc to get the creation date, example:

 

pushd "%directory%"

dir /s /tc /a-d > %Exit%

 

::After that, i dont know how to get only the lines wich the date interval are, example:

 

Today is 19/08/2014, but i want to search all files created from day 10/07/2014. So i have to copy all lines which have the date 10/07/2014, 11/07/2014, 12/07/2014 and so on until stop on today created files.

I tried with findstr but i can't set the date interval, just a specific date to search in the .txt created.

Somebody know how to do that ?

Edited by fudeboy

Well, if you use "ISO" date format it might be easier.

 

Something *like* this:

@ECHO OFFSETLOCAL ENABLEEXTENSIONSFOR /F "tokens=1,2,3,* delims=/ " %%A IN ('DIR /tc /OD C:\batches\') DO (IF %%B leq 12 IF %%C%%B%%A lss 20110322 ECHO %%A/%%B/%%C %%D)

In the above I am using my local settings, where dates are "dd/mm/yyyy" you will need to change order of variables and/or separators to suit your local settings.

 

jaclaz

Sometimes it's more fun to use powershell!

 

InBTween.ps1

$ScriptPath = Split-Path $MyInvocation.MyCommand.Path$ScriptName = $MyInvocation.MyCommand.NamePush-Location $ScriptPath$ToDate = [DateTime]::TodayWrite-Host 'Today is' $ToDate.ToShortDateString()$FromDate = Read-Host 'Enter a Search From Date'If (($FromDate -as [DateTime]) -ne $null) {    $FromDate = [DateTime]::Parse($FromDate)    GCI . -exclude $ScriptName -rec | Sort CreationTime | Where {        $_.CreationTime -ge $FromDate -and $_.CreationTime -le $ToDate    } | % {$_.CreationTime.ToShortDateString() + "`t" + $_.FullName    } | Tee results.txt} Else {    'You did not enter a valid date!'}Write-Host "Press any key to exit . . . " -ForegroundColor Yellow$X = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")Pop-Location

This script is designed to search from the root of its own directory tree and the output will be written to a new file in that directory named results.txt.

 

If the script doesn't run, you may need to type the following into a powershell window first:

Set-ExecutionPolicy RemoteSigned

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.