Solved

Script to scan the machines in the file and search for Mp3 and any song and movie files and move to a UNC location

Posted on 2007-12-05
19
735 Views
Last Modified: 2010-04-24
Hi,

Script to scan the machines in the file and search for Mp3 and any song and movie files and move to a UNC location.
Without user interaction.The files copyed should be copyed to a folder by machine name as the foldername sepeartely.Is there a way to do this.
We have been asked to delete all such files but for a period of time we need to do it in such way.

Regards
Sharath
0
Comment
Question by:bsharath
  • 10
  • 4
  • 3
  • +1
19 Comments
 
LVL 24

Expert Comment

by:fridom
ID: 20417719
Of course one can do it, any decent Shell can be used for it and any decent Scripting language includeing VBScript.
Just search recursivly through all the directories for files ending in .mp3 and then just copy it away.

Regards
Friedrich
0
 
LVL 11

Author Comment

by:bsharath
ID: 20417723
I need to cut and paste in the UNC path
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20418106
Try this as your starupscript Sharath...

Save this as bat file

C:
Cd\
Dir /s *.mp3 *.mpeg *.avi *.mpg > \\Server\Share\%computer%.txt

regards
Chandru
0
 
LVL 11

Author Comment

by:bsharath
ID: 20418222
Chandru can i do this only for a list of computers...
0
 
LVL 24

Expert Comment

by:fridom
ID: 20418539
Sorry, but there is no copying involved. It's just a listing of files.

Regards
Friedrich
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20418550
Do you have enough space to copy files and have it on both the places?
0
 
LVL 11

Author Comment

by:bsharath
ID: 20418564
Yes i have space and need to create the machine names as folder and then move them inside the created folders.Need to move them not copy
0
 
LVL 11

Author Comment

by:bsharath
ID: 20421362
I need to move all files not copy Chandru...
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20421409
But i think the initial post was about copying files
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 11

Author Comment

by:bsharath
ID: 20421438
No chandru my question was
Script to scan the machines in the file and search for Mp3 and any song and movie files and move to a UNC location

Move i meant cut > paste
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20421944
0
 
LVL 26

Accepted Solution

by:
farhankazi earned 500 total points
ID: 20521301
Hi Sharath,
Try following batch script if this works for you!
The script move ALL .mp3, .avi, and .mpg file to specified network share

:: BATCH SCRIPT START 

@ECHO OFF

SETLOCAL EnableDelayedExpansion

SET NetShare=\\server\share

SET InputFile=Machines.txt

IF NOT EXIST "%NetShare%" ECHO Network share not found. &GOTO :EndScript

IF NOT EXIST "%InputFile%" ECHO "%InputFile%" file does not exist. &GOTO :EndScript

FOR %%R IN ("%InputFile%") DO IF %%~zR EQU 0 ECHO "%InputFile%" file is empty. &GOTO :EndScript

FOR /F %%c IN ('TYPE "%InputFile%"') DO (

	ECHO Processing: %%c

	IF NOT EXIST "!NetShare!\%%c" MD "!NetShare!\%%c"

	IF EXIST FileList.txt DEL /F /Q FileList.txt

	FOR /F "delims=: tokens=1" %%d IN ('WMIC /NODE:"%%c" LOGICALDISK WHERE "DriveType=3" GET Name ^|FIND ":"') DO (

		DIR \\%%c\%%d$\*.mp3 /S /B 2>NUL >>FileList.txt

		DIR \\%%c\%%d$\*.avi /S /B 2>NUL >>FileList.txt

		DIR \\%%c\%%d$\*.mpg /S /B 2>NUL >>FileList.txt)

	FOR /F "delims=*" %%f IN ('TYPE FileList.txt ^|FIND "\\"') DO MOVE /Y "%%f" "!NetShare!\%%c\" >NUL 2>&1

	MOVE FileList.txt "!NetShare!\%%c\" >NUL 2>&1)
 

:EndScript

ENDLOCAL

EXIT /B 0

:: BATCH SCRIPT END

Open in new window

0
 
LVL 11

Author Comment

by:bsharath
ID: 20523553
Farhan does this move or just copy from the machines whose names are in the file.
Does it scan just c drive?
0
 
LVL 26

Expert Comment

by:farhankazi
ID: 20523591
>> Does this move or just copy from the machines whose names are in the file.
      Move
>> Does it scan just c drive?
      All fixed drives
0
 
LVL 11

Author Comment

by:bsharath
ID: 20523617
Farhan
The script creates a folder with the machinename and copies the file to the folder.I have the same file for a test in all the drives but it did not cut paste all just the file that i had in the desktop is moved.Can you add a way that if the file has duplicate copies it has to rename and move the file please.
0
 
LVL 11

Author Comment

by:bsharath
ID: 20523624
There is a FileList.txt created in the folder with many paths what are those?
0
 
LVL 26

Expert Comment

by:farhankazi
ID: 20523666
FileList.txt file keeps record of original files location that are moved.
0
 
LVL 11

Author Comment

by:bsharath
ID: 20523695
Farhan
The script creates a folder with the machinename and copies the file to the folder.I have the same file for a test in all the drives but it did not cut paste all just the file that i had in the desktop is moved.Can you add a way that if the file has duplicate copies it has to rename and move the file please.
0
 
LVL 11

Author Comment

by:bsharath
ID: 20532371
Farhan a little more help ...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

929 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now