#1 27 Sep 2020 22:34

SweetTasha
New Member
Registered: 04 Oct 2018
Posts: 4

how to get a file's size as in the dir display

My .bat file
------------------------------------------------------

set "datestamp=%date%"
set "timestamp=%time:~0,8%"
set timestamp=%timestamp::=.%

echo "=.=.=.=.=.=.=.=.=.=.=.=..=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=" >> "C:\Users\pwric\Documents\KEEPASS DATABASE BACKUP\backup log.txt"
echo "Backup on" %datestamp%.%timestamp% >>                        "C:\Users\pwric\Documents\KEEPASS DATABASE BACKUP\backup log.txt"
echo "=.=.=.=.=.=.=.=.=.=.=.=..=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=" >> "C:\Users\pwric\Documents\KEEPASS DATABASE BACKUP\backup log.txt"

copy "C:\Users\pwric\Documents\KeePass Database 2019-03-26.kdbx"  "H:\KeePass Database 2019-03-26.kdbx" /Y

dir "H:\KeePass Database 2019-03-26.kdbx" >> "C:\Users\pwric\Documents\KEEPASS DATABASE BACKUP\backup log.txt"

----------------------------------------------------------------------

That  produces a report like this:

"=.=.=.=.=.=.=.=.=.=.=.=..=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.="
" Backup on Sun 09/27/2020.16.47.00
" =.=.=.=.=.=.=.=.=.=.=.=..=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.="
Volume in drive H is My Book
Volume Serial Number is 76D8-8BA0

Directory of H:\

09/26/2020  02:24 PM            46,462 KeePass Database 2019-03-26.kdbx
               1 File(s)         46,462 bytes
               0 Dir(s)  88,148,791,296 bytes free

I'd like a report like this instead:

"=.=.=.=.=.=.=.=.=.=.=.=..=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.="
" Backup on Sun 09/27/2020.16.47.00
" Database:  KeePass Database 2019-03-26.kdbx 09/26/2020  02:24 PM  46,462
"=.=.=.=.=.=.=.=.=.=.=.=..=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.="

TIA for you suggestions.
SweetTasha.

Offline

#2 28 Sep 2020 11:24

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,118

Re: how to get a file's size as in the dir display

You can use the `for` command to expand metadata for your file, such as the size, and modified date.

If you type for /? at the command prompt it explains about this.

For example:

for %%F in ("H:\KeePass Database 2019-03-26.kdbx") do (
  echo Database: %~nxF %~tzF
)

You can stack the modifier letters, but the elements come out in a predefined order, so some splitting is required for your specific output.

Last edited by bluesxman (28 Sep 2020 11:25)


cmd | *sh | ruby | chef

Offline

Board footer

Powered by FluxBB