[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

For /F search for MP3 files on remote servers

Posted on 2011-02-11
7
Medium Priority
?
472 Views
Last Modified: 2012-05-11
Trying to read through a text file to search remote servers(Win2K3/Win2K8) for *.mp3 items and output to txt (CSV would be even better!).  The text file is C:\Scripts\Server3.txt.  I want to search the D:\Data directories on all servers.  What I have so far is returning error "%%a is unexpected at this time":

FOR /F %%a IN (Servers3.txt) DO DIR /s *.mp3 >>C:\Scripts\MP3.txt

From researching, It appears I may need setlocal enableextensions and/or enabledelayedexpansion.

Also unclear whether it is more efficient to have the text file just read server name(server1) or the network path(\\server1\Data).  

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
7 Comments
 
LVL 5

Assisted Solution

by:Al fa
Al fa earned 300 total points
ID: 34874209
for /f %%f in (Servers3.txt) do dir %%f /s /a /b > C:\Scripts\MP3.txt

Open in new window

0
 

Author Comment

by:LarrySingleton
ID: 34874414
Thanks for the quick response, but I'm still getting "%%f is unexpected at this time".
0
 
LVL 19

Expert Comment

by:Thommy
ID: 34875616
Please provide your complete batch script to solve the problem...
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 

Author Comment

by:LarrySingleton
ID: 34875644
The batch script I attempted was from Ali listed directly under my question:

for /f %%f in (Servers3.txt) do dir %%f /s /a /b > C:\Scripts\MP3.txt

Servers3.txt just lists Server names.

I'll be glad to post whatever additional information you might need...

0
 
LVL 19

Assisted Solution

by:Thommy
Thommy earned 500 total points
ID: 34876101
Error occurs if you start it directly from the command prompt with double "%" like "%%f"!!!

To start it from the command prompt correctly, always omit the first "%":
for /f %f in (Servers3.txt) do dir %f /s /a /b > C:\Scripts\MP3.txt


If you use the command in a batch file, you need double "%":
for /f %%f in (Servers3.txt) do dir %%f /s /a /b > C:\Scripts\MP3.txt


SearchMP3s.cmd
0
 
LVL 58

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 34879976
How about something like this saved to a BAT file?

@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
  )
)

Open in new window

~bp
0
 

Author Comment

by:LarrySingleton
ID: 34889198
I am increasing points and accepting all solutions as Ali provided initial help, but didn't respond to error, Thommy explained the error,but also billprew went on to do the export to CSV.  I am dividing points to Ali, Thommy and billbrew 75/125/125

Thanks to all for your help.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

650 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