Solved

Working for /f script, but need filesizes

Posted on 2011-02-15
5
290 Views
Last Modified: 2012-05-11
I received help before building a script that works great, but I'd like to amend the script to show file sizes of all of the *.mp3 that it finds.  

Here is the script(from billprew):

@echo off
REM Process each line (server name) from server text file
for /F %%A in (Servers3.txt) do (
  REM Find all MP3 files on this server and report it
  for /F "tokens=*" %%B in ('dir /s /a-d /b \\%%A\Data\*.mp3') do (
    echo %%A,%%B>>C:\Scripts\MP3.csv
  )
)

How would we get it to list file sizes of the MP3's it finds into the csv?

thanks!
0
Comment
Question by:LarrySingleton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 16

Expert Comment

by:sjklein42
ID: 34900560
This token will show the size

%%~zB

Open in new window

0
 
LVL 16

Accepted Solution

by:
sjklein42 earned 25 total points
ID: 34900580
Paste into a command window to test:

@for %i in (*) do @echo %i has size %~zi

Open in new window

0
 
LVL 5

Assisted Solution

by:jason987
jason987 earned 75 total points
ID: 34901092
This is what sjklein42 is telling you:

@echo off
REM Process each line (server name) from server text file
for /F %%A in (Servers3.txt) do (
  REM Find all MP3 files on this server and report it
  for /F "tokens=*" %%B in ('dir /s /a-d /b \\%%A\Data\*.mp3') do (
    echo %%A,%%B,%%~zB>>C:\Scripts\MP3.csv
  )
)

Open in new window

0
 

Author Comment

by:LarrySingleton
ID: 34910780
Ok thanks for the response(s).  I am testing now.
0
 

Author Closing Comment

by:LarrySingleton
ID: 34918133
Awarding 25 pts to sjklein42 for partial answer and 75 to jason987 for elaboration/completion.

Thanks to both!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Remote Application Install 5 81
DOS string replace and remove character at end 3 82
Chinese chars file name with 7-zip 11 331
Batch script to delete folder content 3 107
The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question