Sunday, April 12, 2015

windows - command-line / batch file to list all the jar files?


I want to list all the jar files in subdirectories of a specified path, on a Windows computer, along with the file size & times.


dir /s gives me too much information. dir /s *.jar sort of does what I want, but gives me a bunch of information per-directory that I don't care about. dir /b/s *.jar is brief but doesn't give me the time or filesize.


Is there a command that will just list the jar files + filesize/time?


Answer



you could do this:


for /r %i in (*.jar) do echo  %~ti %~zi %i

which will iterate over all dirs (including the current one) and echos out the *.jar names. It will also echo out the echo command, so you may want to pipe the output to a file:


for /r %i in (*.jar) do echo %~ti %~zi %i >> myJars.txt

or put it in a bat:


@echo off
for /r %%i in (*.jar) do echo %%~ti %%~zi %%i

note the double %'s in the .bat version.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...